Skip to content

Commit 128a80a

Browse files
committed
fix(file): enforce single-archive decompress at the API boundary
The block already rejects multiple archives, but the manage route is the real boundary (callable directly and by the LLM tool) and still took the first of multiple resolved inputs. Add the empty-input and >1-archive guards in the route so extra archives are rejected with a clear error rather than silently ignored (cursor).
1 parent 986c294 commit 128a80a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • apps/sim/app/api/tools/file/manage

apps/sim/app/api/tools/file/manage/route.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,16 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
673673
const selectedFileIds = fileId ? [fileId] : extractFileIdsFromInput(fileInput)
674674
const selectedInputFiles = fileId ? [] : extractUserFilesFromInput(fileInput)
675675

676+
if (selectedFileIds.length === 0 && selectedInputFiles.length === 0) {
677+
return NextResponse.json({ success: false, error: 'File is required' }, { status: 400 })
678+
}
679+
if (selectedFileIds.length + selectedInputFiles.length > 1) {
680+
return NextResponse.json(
681+
{ success: false, error: 'Decompress accepts a single .zip archive at a time' },
682+
{ status: 400 }
683+
)
684+
}
685+
676686
const workspaceFiles = await Promise.all(
677687
selectedFileIds.map((id) => getWorkspaceFile(workspaceId, id))
678688
)

0 commit comments

Comments
 (0)