Skip to content

Commit 65dec86

Browse files
committed
fix(firecrawl): treat a blank maxDiscoveryDepth as unset
A cleared field arrived as '' and was sent as 0, a crawl of the start page only. It now follows the blank maxDepth handling.
1 parent 03e0b90 commit 65dec86

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ describe('Firecrawl legacy crawl depth', () => {
106106
apiKey: 'test',
107107
url: 'https://example.com/docs',
108108
maxDepth: '',
109+
maxDiscoveryDepth: ' ',
109110
}
110111
const body = crawlTool.request.body(blankDepth)
111112
if (!isPlainRecord(body)) throw new Error('Expected a JSON request body')
112113
expect(body.includePaths).toBeUndefined()
113114
expect(body.regexOnFullURL).toBeUndefined()
115+
expect(body).not.toHaveProperty('maxDiscoveryDepth')
114116
})
115117
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const crawlTool: ToolConfig<FirecrawlCrawlParams, FirecrawlCrawlResponse>
154154
}
155155

156156
if (params.prompt) body.prompt = params.prompt
157-
if (params.maxDiscoveryDepth != null)
157+
if (params.maxDiscoveryDepth != null && String(params.maxDiscoveryDepth).trim() !== '')
158158
body.maxDiscoveryDepth = Number(params.maxDiscoveryDepth)
159159
if (params.sitemap) body.sitemap = params.sitemap
160160
if (typeof params.crawlEntireDomain === 'boolean')

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ export interface FirecrawlCrawlParams {
290290
formats?: FirecrawlFormat[]
291291
onlyMainContent?: boolean
292292
prompt?: string
293-
maxDiscoveryDepth?: number
293+
/** Raw field text like {@link maxDepth}: a cleared field arrives as `''`. */
294+
maxDiscoveryDepth?: number | string
294295
sitemap?: 'skip' | 'include'
295296
crawlEntireDomain?: boolean
296297
allowExternalLinks?: boolean

0 commit comments

Comments
 (0)