Skip to content

fix(microsoft-excel): clean up dead code found during integration audit#5454

Merged
waleedlatif1 merged 2 commits into
stagingfrom
validate/ms-excel
Jul 7, 2026
Merged

fix(microsoft-excel): clean up dead code found during integration audit#5454
waleedlatif1 merged 2 commits into
stagingfrom
validate/ms-excel

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Ran a full /validate-integration audit of Microsoft Excel (tools, block, types, OAuth scopes) against the live Microsoft Graph API docs — every endpoint, method, and request/response shape checked out correct, and scopes (Files.Read/Files.ReadWrite) already cover every operation, so no OAuth scope changes here
  • Removed unreachable update operation subblocks in the legacy block — leftover from a Google Sheets copy-paste, update was never a dropdown option and isn't handled by the tool selector or any registered tool
  • Fixed microsoft_excel_table_add to trim spreadsheetId and OData-escape tableName, matching every other tool in the file (a table name with an apostrophe would otherwise break the request URL)
  • Dropped phantom/dead type fields: Google-Sheets-only insertDataOption/responseValueRenderOption (never used for Excel), never-populated sheetId/sheetName/title/sheets metadata fields, unused rowIndex, and the unconfigurable majorDimension param (now just hardcoded to 'ROWS')

Type of Change

  • Bug fix / cleanup

Testing

  • bun run type-check — clean
  • bun run check:api-validation — passed
  • bunx biome check — clean
  • bunx vitest run tools/microsoft_excel — 9/9 passing

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

- Remove unreachable 'update' operation subblocks (Google Sheets
  copy-paste leftover — never a selectable dropdown option and not
  handled by the tool selector or any registered tool)
- Fix microsoft_excel_table_add to trim spreadsheetId and OData-escape
  tableName, matching every other tool in this file
- Drop phantom/dead type fields: Google-Sheets-only insertDataOption
  and responseValueRenderOption (never used), never-populated
  sheetId/sheetName/title/sheets metadata fields, unused rowIndex, and
  the unconfigurable majorDimension param (hardcoded to 'ROWS' now
  that it's inlined)
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 7, 2026 12:52am

Request Review

@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Mostly dead-code removal and defensive URL/param validation; write output field mapping is a behavior fix that should match Graph responses more accurately.

Overview
Removes unreachable legacy block UI for a non-existent update operation (values + value input option subblocks that were never wired to a tool).

Microsoft Graph request hardening: read, write, and table-add tools now wrap worksheet/sheet/table names with escapeODataString before OData URL encoding so names with apostrophes don’t break requests. table_add also trims and validates spreadsheetId/tableName and requires an access token in headers, aligned with other Excel tools.

Types and API alignment: drops unused Google Sheets–style params and never-populated metadata fields; write tools always send majorDimension: 'ROWS' instead of a configurable param. Legacy write response mapping now uses Graph range fields (address, rowCount, columnCount) instead of Sheets-style updatedRange/updatedRows fields.

Reviewed by Cursor Bugbot for commit dd765f7. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR audits and cleans up the Microsoft Excel integration, removing dead code copied from the Google Sheets integration and fixing real bugs. The changes are well-scoped and the author confirmed correctness via type-check, API validation, and a full vitest run.

  • Dead code removal: drops unreachable update operation sub-blocks from the block definition (the update dropdown option never existed) and phantom type fields (insertDataOption, responseValueRenderOption, majorDimension, rowIndex, sheetId/sheetName/title/sheets) that only apply to Google Sheets.
  • Bug fix — OData escaping: consistently applies escapeODataString before encodeURIComponent on every sheet/table name passed in an OData key literal (e.g., worksheets('...')), fixing a URL parse error for any name containing an apostrophe.
  • Bug fix — write response fields: writeTool's transformResponse was reading Google Sheets field names (data.updatedRange, data.updatedRows, etc.) that Microsoft Graph never returns; the PR maps to the correct Graph response fields (data.address, data.rowCount, data.columnCount).

Confidence Score: 5/5

Safe to merge — all changes are targeted dead-code removal and correctness fixes for a single integration with no shared dependencies.

The PR removes code that was never reachable and patches two real but contained bugs (OData escaping and write response field mapping) applied consistently across every call site. Tests pass and API shapes were validated.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/tools/microsoft_excel/write.ts Fixes Google Sheets response field names in writeTool transformResponse (address/rowCount/columnCount), applies OData escaping to sheet names, and hardcodes majorDimension to 'ROWS'.
apps/sim/tools/microsoft_excel/table_add.ts Adds OData escaping for tableName, trims spreadsheetId, and adds explicit null checks for required params. Consistent with other tools in the file.
apps/sim/tools/microsoft_excel/read.ts Applies escapeODataString to all sheet name usages before encodeURIComponent, fixing apostrophe-containing sheet names across all read paths.
apps/sim/tools/microsoft_excel/types.ts Removes Google Sheets-only dead type fields (insertDataOption, responseValueRenderOption, majorDimension, rowIndex, sheetId, sheetName, title, sheets) that were never populated or consumed.
apps/sim/blocks/blocks/microsoft_excel.ts Removes two unreachable UI sub-blocks gated on an 'update' operation value that was never offered in the operation dropdown.

Reviews (2): Last reviewed commit: "fix(microsoft-excel): fix write output f..." | Re-trigger Greptile

… gaps

Found in an independent second-pass audit against the live Graph API
docs:

- microsoft_excel_write (v1) transformResponse read
  updatedRange/updatedRows/updatedColumns/updatedCells from the Graph
  response — none of these fields exist on the workbookRange resource
  (the real fields are address/rowCount/columnCount), so these four
  output fields were always undefined. Fixed to read the actual
  fields, matching what the v2 write tool already does correctly.
- read.ts and write.ts (v1 and v2) built worksheets('name') OData
  URLs with only encodeURIComponent, skipping escapeODataString — a
  worksheet name containing an apostrophe would produce a malformed
  request. Every other tool in this integration already escapes
  correctly; read/write were the outliers.
- write.ts (v1) also wasn't trimming spreadsheetId before use,
  inconsistent with every other tool here.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit dd765f7. Configure here.

@waleedlatif1 waleedlatif1 merged commit 03478cd into staging Jul 7, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the validate/ms-excel branch July 7, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant