Skip to content

Commit 780fa90

Browse files
committed
fix(microsoft-excel): unblock OneDrive users and validate driveId in sheets route
- Add credential to any[] arrays so OneDrive users (no drive selected) still pass the dependsOn gate while driveSelector remains in the dependency list for context flow to SharePoint users - Add /^[\w-]+$/ validation for driveId in sheets API route
1 parent a3c93ee commit 780fa90

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

apps/sim/app/api/tools/microsoft_excel/sheets/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export async function GET(request: NextRequest) {
6262
`[${requestId}] Fetching worksheets from Microsoft Graph API for workbook ${spreadsheetId}`
6363
)
6464

65+
if (driveId && !/^[\w-]+$/.test(driveId)) {
66+
return NextResponse.json({ error: 'Invalid drive ID format' }, { status: 400 })
67+
}
68+
6569
const basePath = driveId
6670
? `https://graph.microsoft.com/v1.0/drives/${driveId}/items/${spreadsheetId}`
6771
: `https://graph.microsoft.com/v1.0/me/drive/items/${spreadsheetId}`

apps/sim/blocks/blocks/microsoft_excel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ export const MicrosoftExcelV2Block: BlockConfig<MicrosoftExcelV2Response> = {
431431
requiredScopes: [],
432432
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
433433
placeholder: 'Select a spreadsheet',
434-
dependsOn: { all: ['credential'], any: ['driveSelector'] },
434+
dependsOn: { all: ['credential'], any: ['credential', 'driveSelector'] },
435435
mode: 'basic',
436436
},
437437
// Manual Spreadsheet ID (advanced mode)
@@ -441,7 +441,7 @@ export const MicrosoftExcelV2Block: BlockConfig<MicrosoftExcelV2Response> = {
441441
type: 'short-input',
442442
canonicalParamId: 'spreadsheetId',
443443
placeholder: 'Enter spreadsheet ID',
444-
dependsOn: { all: ['credential'], any: ['manualDriveId'] },
444+
dependsOn: { all: ['credential'], any: ['credential', 'manualDriveId'] },
445445
mode: 'advanced',
446446
},
447447
// Drive ID for SharePoint (advanced mode)
@@ -480,7 +480,7 @@ export const MicrosoftExcelV2Block: BlockConfig<MicrosoftExcelV2Response> = {
480480
required: true,
481481
dependsOn: {
482482
all: ['credential'],
483-
any: ['manualDriveId'],
483+
any: ['credential', 'manualDriveId'],
484484
},
485485
mode: 'advanced',
486486
},

0 commit comments

Comments
 (0)