Skip to content

Commit 28cdf97

Browse files
committed
fix(microsoft-excel): clean up dead code found during integration audit
- 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)
1 parent fb3f95d commit 28cdf97

4 files changed

Lines changed: 26 additions & 60 deletions

File tree

apps/sim/blocks/blocks/microsoft_excel.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -234,41 +234,6 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`,
234234
],
235235
condition: { field: 'operation', value: 'write' },
236236
},
237-
{
238-
id: 'values',
239-
title: 'Values',
240-
type: 'long-input',
241-
placeholder:
242-
'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}])',
243-
condition: { field: 'operation', value: 'update' },
244-
required: true,
245-
wandConfig: {
246-
enabled: true,
247-
prompt: `Generate Microsoft Excel data as a JSON array based on the user's description.
248-
249-
Format options:
250-
1. Array of arrays: [["Header1", "Header2"], ["Value1", "Value2"]]
251-
2. Array of objects: [{"column1": "value1", "column2": "value2"}]
252-
253-
Examples:
254-
- "update with new prices" -> [["Product", "Price"], ["Widget A", 29.99], ["Widget B", 49.99]]
255-
- "quarterly targets" -> [{"Q1": 10000, "Q2": 12000, "Q3": 15000, "Q4": 18000}]
256-
257-
Return ONLY the JSON array - no explanations, no markdown, no extra text.`,
258-
placeholder: 'Describe the data you want to update...',
259-
generationType: 'json-object',
260-
},
261-
},
262-
{
263-
id: 'valueInputOption',
264-
title: 'Value Input Option',
265-
type: 'dropdown',
266-
options: [
267-
{ label: 'User Entered (Parse formulas)', id: 'USER_ENTERED' },
268-
{ label: "Raw (Don't parse formulas)", id: 'RAW' },
269-
],
270-
condition: { field: 'operation', value: 'update' },
271-
},
272237
{
273238
id: 'values',
274239
title: 'Values',

apps/sim/tools/microsoft_excel/table_add.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import type {
33
MicrosoftExcelTableAddResponse,
44
MicrosoftExcelTableToolParams,
55
} from '@/tools/microsoft_excel/types'
6-
import { getItemBasePath, getSpreadsheetWebUrl } from '@/tools/microsoft_excel/utils'
6+
import {
7+
escapeODataString,
8+
getItemBasePath,
9+
getSpreadsheetWebUrl,
10+
} from '@/tools/microsoft_excel/utils'
711
import type { ToolConfig } from '@/tools/types'
812

913
export const tableAddTool: ToolConfig<
@@ -59,15 +63,27 @@ export const tableAddTool: ToolConfig<
5963

6064
request: {
6165
url: (params) => {
62-
const tableName = encodeURIComponent(params.tableName)
63-
const basePath = getItemBasePath(params.spreadsheetId, params.driveId)
64-
return `${basePath}/workbook/tables('${tableName}')/rows/add`
66+
const spreadsheetId = params.spreadsheetId?.trim()
67+
if (!spreadsheetId) {
68+
throw new Error('Spreadsheet ID is required')
69+
}
70+
const tableName = params.tableName?.trim()
71+
if (!tableName) {
72+
throw new Error('Table name is required')
73+
}
74+
const basePath = getItemBasePath(spreadsheetId, params.driveId)
75+
return `${basePath}/workbook/tables('${encodeURIComponent(escapeODataString(tableName))}')/rows/add`
6576
},
6677
method: 'POST',
67-
headers: (params) => ({
68-
Authorization: `Bearer ${params.accessToken}`,
69-
'Content-Type': 'application/json',
70-
}),
78+
headers: (params) => {
79+
if (!params.accessToken) {
80+
throw new Error('Access token is required')
81+
}
82+
return {
83+
Authorization: `Bearer ${params.accessToken}`,
84+
'Content-Type': 'application/json',
85+
}
86+
},
7187
body: (params) => {
7288
let processedValues: any = params.values || []
7389

apps/sim/tools/microsoft_excel/types.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,13 @@ import type { ToolResponse } from '@/tools/types'
44
export type ExcelCellValue = string | number | boolean | null
55

66
interface MicrosoftExcelRange {
7-
sheetId?: number
8-
sheetName?: string
97
range: string
108
values: ExcelCellValue[][]
119
}
1210

1311
interface MicrosoftExcelMetadata {
1412
spreadsheetId: string
1513
spreadsheetUrl?: string
16-
title?: string
17-
sheets?: {
18-
sheetId: number
19-
title: string
20-
index: number
21-
rowCount?: number
22-
columnCount?: number
23-
}[]
2414
}
2515

2616
export interface MicrosoftExcelReadResponse extends ToolResponse {
@@ -67,10 +57,7 @@ export interface MicrosoftExcelToolParams {
6757
range?: string
6858
values?: ExcelCellValue[][]
6959
valueInputOption?: 'RAW' | 'USER_ENTERED'
70-
insertDataOption?: 'OVERWRITE' | 'INSERT_ROWS'
7160
includeValuesInResponse?: boolean
72-
responseValueRenderOption?: 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA'
73-
majorDimension?: 'ROWS' | 'COLUMNS'
7461
}
7562

7663
export interface MicrosoftExcelTableToolParams {
@@ -79,7 +66,6 @@ export interface MicrosoftExcelTableToolParams {
7966
driveId?: string
8067
tableName: string
8168
values: ExcelCellValue[][]
82-
rowIndex?: number
8369
}
8470

8571
export interface MicrosoftExcelWorksheetToolParams {
@@ -217,7 +203,6 @@ export interface MicrosoftExcelV2ToolParams {
217203
values?: ExcelCellValue[][]
218204
valueInputOption?: 'RAW' | 'USER_ENTERED'
219205
includeValuesInResponse?: boolean
220-
majorDimension?: 'ROWS' | 'COLUMNS'
221206
}
222207

223208
export interface MicrosoftExcelV2ReadResponse extends ToolResponse {

apps/sim/tools/microsoft_excel/write.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const writeTool: ToolConfig<MicrosoftExcelToolParams, MicrosoftExcelWrite
145145
}
146146

147147
const body: Record<string, any> = {
148-
majorDimension: params.majorDimension || 'ROWS',
148+
majorDimension: 'ROWS',
149149
values: processedValues,
150150
}
151151

@@ -337,7 +337,7 @@ export const writeV2Tool: ToolConfig<MicrosoftExcelV2ToolParams, MicrosoftExcelV
337337
}
338338

339339
const body: Record<string, any> = {
340-
majorDimension: params.majorDimension || 'ROWS',
340+
majorDimension: 'ROWS',
341341
values: processedValues,
342342
}
343343

0 commit comments

Comments
 (0)