Skip to content

Commit 5bb3903

Browse files
committed
fix(google_sheets): fail fast on non-numeric delete indices
Address Cursor Bugbot: delete_sheet/delete_rows parsed deleteSheetId/startIndex/ endIndex with Number.parseInt but didn't validate, so non-numeric UI input became NaN and was forwarded (the v2 delete tools only reject null/undefined), breaking the batchUpdate. The block now throws a clear error when any of these is not a valid number.
1 parent b8ad167 commit 5bb3903

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

apps/sim/blocks/blocks/google_sheets.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,20 +908,34 @@ Return ONLY the JSON array - no explanations, no markdown, no extra text.`,
908908

909909
// Handle delete_sheet operation
910910
if (operation === 'delete_sheet') {
911+
const parsedSheetId = Number.parseInt(deleteSheetId as string, 10)
912+
if (Number.isNaN(parsedSheetId)) {
913+
throw new Error('Sheet ID must be a valid number')
914+
}
911915
return {
912916
spreadsheetId: effectiveSpreadsheetId,
913-
sheetId: Number.parseInt(deleteSheetId as string, 10),
917+
sheetId: parsedSheetId,
914918
oauthCredential,
915919
}
916920
}
917921

918922
// Handle delete_rows operation
919923
if (operation === 'delete_rows') {
924+
const parsedSheetId = Number.parseInt(deleteSheetId as string, 10)
925+
const parsedStartIndex = Number.parseInt(startIndex as string, 10)
926+
const parsedEndIndex = Number.parseInt(endIndex as string, 10)
927+
if (
928+
Number.isNaN(parsedSheetId) ||
929+
Number.isNaN(parsedStartIndex) ||
930+
Number.isNaN(parsedEndIndex)
931+
) {
932+
throw new Error('Sheet ID, start index, and end index must be valid numbers')
933+
}
920934
return {
921935
spreadsheetId: effectiveSpreadsheetId,
922-
sheetId: Number.parseInt(deleteSheetId as string, 10),
923-
startIndex: Number.parseInt(startIndex as string, 10),
924-
endIndex: Number.parseInt(endIndex as string, 10),
936+
sheetId: parsedSheetId,
937+
startIndex: parsedStartIndex,
938+
endIndex: parsedEndIndex,
925939
oauthCredential,
926940
}
927941
}

0 commit comments

Comments
 (0)