From 28cdf97f54c7489cb53724d35fd78c7597d015c7 Mon Sep 17 00:00:00 2001 From: waleed Date: Mon, 6 Jul 2026 17:44:11 -0700 Subject: [PATCH 1/2] fix(microsoft-excel): clean up dead code found during integration audit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- apps/sim/blocks/blocks/microsoft_excel.ts | 35 --------------------- apps/sim/tools/microsoft_excel/table_add.ts | 32 ++++++++++++++----- apps/sim/tools/microsoft_excel/types.ts | 15 --------- apps/sim/tools/microsoft_excel/write.ts | 4 +-- 4 files changed, 26 insertions(+), 60 deletions(-) diff --git a/apps/sim/blocks/blocks/microsoft_excel.ts b/apps/sim/blocks/blocks/microsoft_excel.ts index 4d05101cbed..4312a5b370a 100644 --- a/apps/sim/blocks/blocks/microsoft_excel.ts +++ b/apps/sim/blocks/blocks/microsoft_excel.ts @@ -234,41 +234,6 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`, ], condition: { field: 'operation', value: 'write' }, }, - { - id: 'values', - title: 'Values', - type: 'long-input', - placeholder: - 'Enter values as JSON array of arrays (e.g., [["A1", "B1"], ["A2", "B2"]]) or an array of objects (e.g., [{"name":"John", "age":30}, {"name":"Jane", "age":25}])', - condition: { field: 'operation', value: 'update' }, - required: true, - wandConfig: { - enabled: true, - prompt: `Generate Microsoft Excel data as a JSON array based on the user's description. - -Format options: -1. Array of arrays: [["Header1", "Header2"], ["Value1", "Value2"]] -2. Array of objects: [{"column1": "value1", "column2": "value2"}] - -Examples: -- "update with new prices" -> [["Product", "Price"], ["Widget A", 29.99], ["Widget B", 49.99]] -- "quarterly targets" -> [{"Q1": 10000, "Q2": 12000, "Q3": 15000, "Q4": 18000}] - -Return ONLY the JSON array - no explanations, no markdown, no extra text.`, - placeholder: 'Describe the data you want to update...', - generationType: 'json-object', - }, - }, - { - id: 'valueInputOption', - title: 'Value Input Option', - type: 'dropdown', - options: [ - { label: 'User Entered (Parse formulas)', id: 'USER_ENTERED' }, - { label: "Raw (Don't parse formulas)", id: 'RAW' }, - ], - condition: { field: 'operation', value: 'update' }, - }, { id: 'values', title: 'Values', diff --git a/apps/sim/tools/microsoft_excel/table_add.ts b/apps/sim/tools/microsoft_excel/table_add.ts index bdd06f9e2a2..2c85f42ffc9 100644 --- a/apps/sim/tools/microsoft_excel/table_add.ts +++ b/apps/sim/tools/microsoft_excel/table_add.ts @@ -3,7 +3,11 @@ import type { MicrosoftExcelTableAddResponse, MicrosoftExcelTableToolParams, } from '@/tools/microsoft_excel/types' -import { getItemBasePath, getSpreadsheetWebUrl } from '@/tools/microsoft_excel/utils' +import { + escapeODataString, + getItemBasePath, + getSpreadsheetWebUrl, +} from '@/tools/microsoft_excel/utils' import type { ToolConfig } from '@/tools/types' export const tableAddTool: ToolConfig< @@ -59,15 +63,27 @@ export const tableAddTool: ToolConfig< request: { url: (params) => { - const tableName = encodeURIComponent(params.tableName) - const basePath = getItemBasePath(params.spreadsheetId, params.driveId) - return `${basePath}/workbook/tables('${tableName}')/rows/add` + const spreadsheetId = params.spreadsheetId?.trim() + if (!spreadsheetId) { + throw new Error('Spreadsheet ID is required') + } + const tableName = params.tableName?.trim() + if (!tableName) { + throw new Error('Table name is required') + } + const basePath = getItemBasePath(spreadsheetId, params.driveId) + return `${basePath}/workbook/tables('${encodeURIComponent(escapeODataString(tableName))}')/rows/add` }, method: 'POST', - headers: (params) => ({ - Authorization: `Bearer ${params.accessToken}`, - 'Content-Type': 'application/json', - }), + headers: (params) => { + if (!params.accessToken) { + throw new Error('Access token is required') + } + return { + Authorization: `Bearer ${params.accessToken}`, + 'Content-Type': 'application/json', + } + }, body: (params) => { let processedValues: any = params.values || [] diff --git a/apps/sim/tools/microsoft_excel/types.ts b/apps/sim/tools/microsoft_excel/types.ts index a3d3bc42d34..ed5a3123587 100644 --- a/apps/sim/tools/microsoft_excel/types.ts +++ b/apps/sim/tools/microsoft_excel/types.ts @@ -4,8 +4,6 @@ import type { ToolResponse } from '@/tools/types' export type ExcelCellValue = string | number | boolean | null interface MicrosoftExcelRange { - sheetId?: number - sheetName?: string range: string values: ExcelCellValue[][] } @@ -13,14 +11,6 @@ interface MicrosoftExcelRange { interface MicrosoftExcelMetadata { spreadsheetId: string spreadsheetUrl?: string - title?: string - sheets?: { - sheetId: number - title: string - index: number - rowCount?: number - columnCount?: number - }[] } export interface MicrosoftExcelReadResponse extends ToolResponse { @@ -67,10 +57,7 @@ export interface MicrosoftExcelToolParams { range?: string values?: ExcelCellValue[][] valueInputOption?: 'RAW' | 'USER_ENTERED' - insertDataOption?: 'OVERWRITE' | 'INSERT_ROWS' includeValuesInResponse?: boolean - responseValueRenderOption?: 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA' - majorDimension?: 'ROWS' | 'COLUMNS' } export interface MicrosoftExcelTableToolParams { @@ -79,7 +66,6 @@ export interface MicrosoftExcelTableToolParams { driveId?: string tableName: string values: ExcelCellValue[][] - rowIndex?: number } export interface MicrosoftExcelWorksheetToolParams { @@ -217,7 +203,6 @@ export interface MicrosoftExcelV2ToolParams { values?: ExcelCellValue[][] valueInputOption?: 'RAW' | 'USER_ENTERED' includeValuesInResponse?: boolean - majorDimension?: 'ROWS' | 'COLUMNS' } export interface MicrosoftExcelV2ReadResponse extends ToolResponse { diff --git a/apps/sim/tools/microsoft_excel/write.ts b/apps/sim/tools/microsoft_excel/write.ts index 0420c753648..98062b88dcb 100644 --- a/apps/sim/tools/microsoft_excel/write.ts +++ b/apps/sim/tools/microsoft_excel/write.ts @@ -145,7 +145,7 @@ export const writeTool: ToolConfig = { - majorDimension: params.majorDimension || 'ROWS', + majorDimension: 'ROWS', values: processedValues, } @@ -337,7 +337,7 @@ export const writeV2Tool: ToolConfig = { - majorDimension: params.majorDimension || 'ROWS', + majorDimension: 'ROWS', values: processedValues, } From dd765f73c5eea4a1cc0d3c5418ea4354087ab6cf Mon Sep 17 00:00:00 2001 From: waleed Date: Mon, 6 Jul 2026 17:52:24 -0700 Subject: [PATCH 2/2] fix(microsoft-excel): fix write output field mapping + OData escaping gaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- apps/sim/tools/microsoft_excel/read.ts | 9 +++++---- apps/sim/tools/microsoft_excel/write.ts | 25 +++++++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/sim/tools/microsoft_excel/read.ts b/apps/sim/tools/microsoft_excel/read.ts index adf4ab53850..fe18103b563 100644 --- a/apps/sim/tools/microsoft_excel/read.ts +++ b/apps/sim/tools/microsoft_excel/read.ts @@ -7,6 +7,7 @@ import type { MicrosoftExcelV2ToolParams, } from '@/tools/microsoft_excel/types' import { + escapeODataString, getItemBasePath, getSpreadsheetWebUrl, parseGraphErrorMessage, @@ -79,7 +80,7 @@ export const readTool: ToolConfig { + const spreadsheetId = params.spreadsheetId?.trim() + if (!spreadsheetId) { + throw new Error('Spreadsheet ID is required') + } + const rangeInput = params.range?.trim() const match = rangeInput?.match(/^([^!]+)!(.+)$/) @@ -89,10 +98,10 @@ export const writeTool: ToolConfig