Skip to content

Commit f5ef0eb

Browse files
committed
fix(files): refuse unresolved xlsx source
1 parent acf9397 commit f5ef0eb

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

apps/sim/lib/copilot/tools/server/files/doc-compile.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,9 @@ export async function resolveServableDocBytes(args: {
541541
}
542542
}
543543

544-
// Reaches here only for xlsx, which has no isolated-vm fallback. With workspace
545-
// context, returning these bytes would expose generation source as a spreadsheet.
546-
if (!format) {
547-
if (workspaceId) throw new DocCompileUserError('Document is still being generated')
548-
return { buffer: rawBuffer, contentType: getContentType(fileName) }
549-
}
544+
// Reaches here only for xlsx, which has no isolated-vm fallback. Returning these
545+
// bytes would expose generation source as a spreadsheet.
546+
if (!format) throw new DocCompileUserError('Document is still being generated')
550547

551548
const cacheKey = sha256Hex(`${ext}${source}${workspaceId ?? ''}`)
552549
const cached = compiledDocCache.get(cacheKey)

apps/sim/lib/copilot/tools/server/files/doc-servable.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,15 @@ describe('resolveServableDocBytes', () => {
173173
expect(mockRunSandboxTask).not.toHaveBeenCalled()
174174
})
175175

176-
it('returns raw XLSX source when there is no workspaceId (xlsx has no isolated-vm path)', async () => {
177-
const result = await resolveServableDocBytes({
178-
rawBuffer: XLSX_SOURCE,
179-
fileName: 'sheet.xlsx',
180-
workspaceId: undefined,
181-
})
176+
it('throws instead of returning XLSX source when there is no workspaceId', async () => {
177+
await expect(
178+
resolveServableDocBytes({
179+
rawBuffer: XLSX_SOURCE,
180+
fileName: 'sheet.xlsx',
181+
workspaceId: undefined,
182+
})
183+
).rejects.toBeInstanceOf(DocCompileUserError)
182184

183-
expect(result.buffer).toBe(XLSX_SOURCE)
184185
expect(mockLoadCompiledDoc).not.toHaveBeenCalled()
185186
expect(mockRunSandboxTask).not.toHaveBeenCalled()
186187
})

0 commit comments

Comments
 (0)