Repository navigation
fix(js-sdk): omit empty auth header for self-hosted instances - #3046
debgotwired wants to merge 14 commits into
Conversation
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/js-sdk/firecrawl/src/v1/index.ts">
<violation number="1" location="apps/js-sdk/firecrawl/src/v1/index.ts:25">
P2: Cloud auth validation still accepts empty/whitespace API keys; with the new truthy auth-header check, clients can initialize and fail later instead of failing fast.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Follow-up pushed. cubic identified a valid issue: cloud-path constructors still accepted whitespace-only API keys after the self-host auth-header change. I normalized the API key in both v1 and v2 so cloud usage still fails fast on blank or whitespace-only keys, and added focused unit coverage for that path while keeping the self-host wire-level header tests green. |
|
One note on the failing Vercel status: from the PR metadata it looks like the failure is coming from Vercel Git authorization for the Firecrawl team/project on this fork PR, not from a code/test failure in this branch. The actual code review issue identified by cubic was fixed in commit fee1e25 with focused tests. If needed, maintainers may want to ignore or re-run the Vercel integration separately from code review. |
There was a problem hiding this comment.
7 issues found across 13 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/js-sdk/firecrawl/src/v2/types.ts">
<violation number="1" location="apps/js-sdk/firecrawl/src/v2/types.ts:474">
P2: Newly added CrawlOptions fields are not serialized into the crawl request payload, causing typed options to be ignored at runtime.</violation>
</file>
<file name="apps/api/src/controllers/v1/types.ts">
<violation number="1" location="apps/api/src/controllers/v1/types.ts:47">
P2: User-Agent merge check is case-sensitive, so existing `user-agent` headers are not recognized and a duplicate/conflicting `User-Agent` key can be added.</violation>
<violation number="2" location="apps/api/src/controllers/v1/types.ts:475">
P2: `robotsMode` is added to crawler options but not propagated through legacy/new conversion helpers, causing semantic loss across persisted/translated crawl options.</violation>
</file>
<file name="apps/api/src/scraper/WebScraper/crawler.ts">
<violation number="1" location="apps/api/src/scraper/WebScraper/crawler.ts:408">
P2: Robots UA extraction is case-sensitive (`"User-Agent"` only), so lowercase `user-agent` headers can cause robots checks/crawl-delay to use fallback agents instead of the actual request UA.</violation>
</file>
<file name="apps/api/src/controllers/v2/types.ts">
<violation number="1" location="apps/api/src/controllers/v2/types.ts:93">
P2: User-Agent insertion uses case-sensitive key detection, allowing duplicate/conflicting header keys when caller uses different casing.</violation>
<violation number="2" location="apps/api/src/controllers/v2/types.ts:566">
P2: `robotsMode` is introduced but not mapped in v0↔v2 crawler option converters, causing semantic data loss across stored/retrieved crawl options.</violation>
</file>
<file name="apps/api/src/scraper/scrapeURL/index.ts">
<violation number="1" location="apps/api/src/scraper/scrapeURL/index.ts:955">
P2: Robots user-agent extraction is case-sensitive, so custom `user-agent` headers can be ignored and robots allow/deny checks may use the wrong agent.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| crawlEntireDomain?: boolean; | ||
| allowExternalLinks?: boolean; | ||
| allowSubdomains?: boolean; | ||
| ignoreRobotsTxt?: boolean; |
There was a problem hiding this comment.
P2: Newly added CrawlOptions fields are not serialized into the crawl request payload, causing typed options to be ignored at runtime.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/js-sdk/firecrawl/src/v2/types.ts, line 474:
<comment>Newly added CrawlOptions fields are not serialized into the crawl request payload, causing typed options to be ignored at runtime.</comment>
<file context>
@@ -469,6 +471,8 @@ export interface CrawlOptions {
crawlEntireDomain?: boolean;
allowExternalLinks?: boolean;
allowSubdomains?: boolean;
+ ignoreRobotsTxt?: boolean;
+ robotsMode?: 'ignore' | 'respect' | 'strict';
delay?: number | null;
</file context>
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/lib/robots-policy.ts">
<violation number="1" location="apps/api/src/lib/robots-policy.ts:68">
P2: Falsy cache check misclassifies empty-string cached robots.txt as a cache miss, causing unnecessary refetches and possible strict-mode false denials.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Follow-up pushed. cubic found a valid set of robots-related edge cases, and I fixed them in 21d6947 with focused tests. Changes included: preserving robotsMode through legacy/v0 crawler option converters, treating user-agent headers case-insensitively to avoid duplicate/conflicting keys, serializing crawl-level ignoreRobotsTxt and robotsMode from the JS SDK, and treating empty-string cached robots.txt as a real cache hit instead of refetching. Verification run before push: robots-policy.test.ts, v1/v2 types-validation suites, JS SDK unit tests including a new crawl payload test, and the JS SDK build. @cubic-dev-ai please re-run review. |
@debgotwired I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
2 issues found across 24 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/scraper/WebScraper/crawler.ts">
<violation number="1" location="apps/api/src/scraper/WebScraper/crawler.ts:406">
P2: Robots filtering is inconsistent: JS checks are now user-agent aware, but the primary Rust `filterLinks` path still lacks user-agent context, causing potential allow/deny mismatches.</violation>
</file>
<file name="apps/api/src/controllers/v2/crawl.ts">
<violation number="1" location="apps/api/src/controllers/v2/crawl.ts:208">
P1: Strict robots.txt failure handling reads `req.body.robotsMode` instead of merged effective crawler options, so strict mode from merged prompt options may be ignored.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Follow-up pushed. cubic found two more valid issues, and I fixed them in 7c2fed0 with focused tests. The first was a real P1: strict robots startup handling in v2 crawl was checking req.body.robotsMode instead of the merged effective crawler options, so prompt-generated strict mode could be ignored. The second was a real consistency gap: when robots checks depend on a custom user-agent, WebCrawler.filterLinks now skips the Rust path and falls back to the user-agent-aware JS path instead of producing mismatched allow/deny behavior. Verification run before push: robots-runtime-policy.test.ts, robots-policy.test.ts, and the v1/v2 types-validation suites. @cubic-dev-ai please re-run review. |
@debgotwired I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
2 issues found across 26 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/scraper/WebScraper/crawler.ts">
<violation number="1" location="apps/api/src/scraper/WebScraper/crawler.ts:185">
P2: Custom user-agent routing now increases use of JS filtering path that inconsistently reparses links without a base, causing valid relative links to be dropped.</violation>
</file>
<file name="apps/api/src/lib/robots-policy.ts">
<violation number="1" location="apps/api/src/lib/robots-policy.ts:103">
P2: Abort/cancellation errors from robots fetch are swallowed in respect mode, so cancellation may not stop scraping at this stage.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Fixed the two latest cubic findings in commit a3c2eee.
Verification run before push:
One existing local limitation is unchanged: the full crawler test suite is still blocked by the repo native and type resolution setup around @mendable/firecrawl-rs, so the relative-link regression is covered through the extracted helper test for now. |
There was a problem hiding this comment.
2 issues found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/scraper/WebScraper/link-normalization.ts">
<violation number="1" location="apps/api/src/scraper/WebScraper/link-normalization.ts:6">
P2: `resolveCrawlerLink` does not reject empty or fragment-only hrefs, allowing self-referential/duplicate crawl targets to pass JS link filtering.</violation>
<violation number="2" location="apps/api/src/scraper/WebScraper/link-normalization.ts:6">
P2: `resolveCrawlerLink` accepts any URL scheme; it should allowlist `http`/`https` to prevent non-web schemes from being treated as valid crawl targets.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
The two latest helper issues were valid and are fixed in commit 90cc48c.
Verification run before push:
|
|
Proactive hardening sweep pushed in commit db10dc5. In addition to the issues cubic previously identified, I found and fixed three adjacent correctness gaps while reviewing the full touched surface:
Verification run before push:
This was a preemptive sweep to reduce another round of piecemeal follow-up comments. @cubic-dev-ai please re-run review. |
@debgotwired I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 28 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/js-sdk/firecrawl/src/v1/index.ts">
<violation number="1" location="apps/js-sdk/firecrawl/src/v1/index.ts:704">
P2: Calling `apiKey?.trim()` without a type guard can throw a runtime `TypeError` for non-string inputs, causing an uncaught exception before SDK validation/fallback logic.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
cubic identified a valid JS SDK issue in the v1 constructor, and I fixed it in commit 48cf274. Root cause: the constructor was calling apiKey?.trim() directly, so non-string runtime inputs could throw a raw TypeError before validation. What changed:
Verification run before push:
@cubic-dev-ai please re-run review. |
@debgotwired I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
2 issues found across 28 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/controllers/v1/types.ts">
<violation number="1" location="apps/api/src/controllers/v1/types.ts:478">
P2: `mapRequestSchema` accepts `robotsMode` but never applies the new `normalizeHeadersAndRobots` transform, so Map requests may not derive `ignoreRobotsTxt` from `robotsMode` as intended.</violation>
</file>
<file name="apps/api/src/scraper/scrapeURL/index.ts">
<violation number="1" location="apps/api/src/scraper/scrapeURL/index.ts:980">
P1: Strict robots verification errors are thrown outside the main scrapeURL error-handling path, causing promise rejection instead of a consistent ScrapeUrlResponse failure.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Both latest reports were valid, and I fixed them in commit 6800793.
I also applied the same map-schema normalization fix in v2 preemptively, since it had the same omission. Verification run before push:
@cubic-dev-ai please re-run review. |
@debgotwired I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 7 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/scraper/scrapeURL/index.ts">
<violation number="1" location="apps/api/src/scraper/scrapeURL/index.ts:997">
P2: Robots-check failure response is returned from the catch handler but ignored, so robots-denied errors do not stop the scrape and the pipeline continues anyway.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
3 issues found across 28 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/scraper/scrapeURL/index.ts">
<violation number="1" location="apps/api/src/scraper/scrapeURL/index.ts:997">
P2: Robots check failures are converted to `{ success: false }` in the catch handler but the result is never returned or inspected, so scraping continues even after a robots.txt denial or strict verification failure.</violation>
</file>
<file name="apps/api/src/lib/robots-txt.ts">
<violation number="1" location="apps/api/src/lib/robots-txt.ts:146">
P2: Adding the derived UA token makes robots checks permissive: a robots.txt rule that disallows the exact UA (e.g., "MyBot/1.0") but allows the derived token ("MyBot") will now be treated as allowed because isUrlAllowedByRobots returns true on the first allowed candidate.</violation>
</file>
<file name="apps/api/src/scraper/WebScraper/crawler.ts">
<violation number="1" location="apps/api/src/scraper/WebScraper/crawler.ts:186">
P2: When shouldUseJsFiltering is true, the crawler skips the Rust filter and uses the JS path that does not enforce allowExternalContentLinks/allowSubdomains (hostname guard is commented out), allowing external links to pass even when external crawling is disabled and evaluating robots.txt against the wrong domain.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
The latest three reports were valid, and I fixed them in commit c57d581. What changed:
Verification run before push:
I extracted the robots-access and crawl-target policy seams into focused helpers so these edge cases stay directly testable even with the repo native-module limitations. @cubic-dev-ai please re-run review. |
@debgotwired I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 32 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/lib/robots-access.ts">
<violation number="1" location="apps/api/src/lib/robots-access.ts:22">
P2: Trailing-slash fallback appends to the full URL string, which corrupts URLs with query/fragment and can trigger false robots denials. The slash should be added to the pathname before re-serializing the URL.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Fix robots-access URL trailing-slash fallback to manipulate pathname via URL object instead of raw string concatenation, preventing corruption of URLs with query strings or fragments - Align map controllers with crawl controllers by using the shouldFailClosedOnInitialRobotsFetch policy function instead of direct robotsMode === "strict" comparison - Add unit test for trailing-slash check with query-string URLs Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Follow-up pushed in 38d2ff2. Fixes:
Re: CrawlOptions serialization comment (cubic P2 on Requesting re-review. |
|
Closing: the diff is a large robotsMode/userAgent feature across the API and SDK rather than the auth-header fix in the title, so it isn't reviewable as one change; thanks for the contribution. |
Summary
Why
Self-hosted instances with authentication disabled should work without sending an empty bearer token like , which can cause avoidable auth failures.
Testing
Summary by cubic
Stop sending the Authorization header in
@mendable/firecrawl-jsfor self-hosted instances without an API key, and add robots controls (robotsMode,userAgent) with strict, UA‑aware enforcement across scrape, crawl, and map. Also fix robots trailing‑slash checks and align map strict‑mode handling.New Features
robotsMode(ignore|respect|strict) and normalizeuserAgentinto headers; strict mode fails closed on robots verification errors and disallowed URLs; deriveignoreRobotsTxtfrom mode. WebCrawler: UA‑aware allow/deny and crawl delay, registrable‑domain external link policy, and JS link filtering when UA‑specific evaluation is required; link normalization drops invalid, fragment‑only, and non‑http(s) URLs. SDK v1/v2: exposerobotsModeanduserAgent(included in v2 crawl payload); docs add examples for robots controls and self‑hosted usage withoutapiKey.Bug Fixes
apiKeyinputs (reject whitespace‑only for cloud, avoid TypeErrors) and only setAuthorizationwhen non‑empty; self‑hosted omitsAuthorizationin v1/v2 and on the wire; tests cover both paths. API v1/v2: enforce strict mode across scrape, crawl, and map; pass caller UA to robots fetch/evaluation; treat abort‑shaped errors as cancellations; treat empty cached robots as a cache hit; avoid duplicate/case‑variant UA headers; preserverobotsModethrough v1/v2 option conversions; improve denial reason mapping; return failed scrape responses for robots denials and strict verification failures. Robots: fix trailing‑slash check by modifying URL pathname (preserves query/fragment) and align map controllers withshouldFailClosedOnInitialRobotsFetch; add unit test for query‑string case.Written for commit 38d2ff2. Summary will update on new commits.