Skip to content

Commit 01b1998

Browse files
committed
fix(integrations): fail a firecrawl crawl or batch scrape that returned no job id
1 parent 5f8335b commit 01b1998

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎apps/sim/tools/firecrawl/batch-scrape.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ export const batchScrapeTool: ToolConfig<FirecrawlBatchScrapeParams, FirecrawlBa
192192
}
193193

194194
const jobId = result.output.jobId
195+
if (!jobId) {
196+
return {
197+
...result,
198+
success: false,
199+
error: 'Firecrawl did not return a batch scrape job ID to poll',
200+
}
201+
}
195202
const signal = context?.signal
196203
const invalidURLs = result.output.invalidURLs ?? []
197204
logger.info(`Firecrawl batch scrape job ${jobId} created, polling for completion...`)

‎apps/sim/tools/firecrawl/crawl.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ export const crawlTool: ToolConfig<FirecrawlCrawlParams, FirecrawlCrawlResponse>
240240
}
241241

242242
const jobId = result.output.jobId
243+
if (!jobId) {
244+
return { ...result, success: false, error: 'Firecrawl did not return a crawl job ID to poll' }
245+
}
243246
const signal = context?.signal
244247
logger.info(`Firecrawl crawl job ${jobId} created, polling for completion...`)
245248

‎apps/sim/tools/firecrawl/job-polling.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ describe('Firecrawl crawl polling', () => {
5151
expect.objectContaining({ method: 'DELETE' })
5252
)
5353
})
54+
55+
it('fails at once instead of polling when Firecrawl returned no job ID', async () => {
56+
if (!crawlTool.postProcess) throw new Error('crawlTool has no postProcess')
57+
const result = await crawlTool.postProcess(
58+
{ success: true, output: { pages: [], total: 0 } },
59+
params,
60+
executeTool
61+
)
62+
63+
expect(result).toMatchObject({ success: false, error: expect.stringMatching(/job ID/) })
64+
expect(fetchMock).not.toHaveBeenCalled()
65+
})
5466
})

0 commit comments

Comments
 (0)