Skip to content

fix(js-sdk): omit empty auth header for self-hosted instances - #3046

Closed
debgotwired wants to merge 14 commits into
firecrawl:mainfrom
debgotwired:fix/selfhost-no-empty-auth-header
Closed

debgotwired wants to merge 14 commits into
firecrawl:mainfrom
debgotwired:fix/selfhost-no-empty-auth-header

Conversation

@debgotwired

@debgotwired debgotwired commented Mar 9, 2026 •

Copy link
Copy Markdown

Summary

  • omit the Authorization header entirely when the JS SDK is pointed at a self-hosted Firecrawl instance without an API key
  • apply the same behavior to the legacy v1 client header builder
  • document self-hosted JS SDK usage and add unit coverage for both v1 and v2

Why

Self-hosted instances with authentication disabled should work without sending an empty bearer token like , which can cause avoidable auth failures.

Testing

  •  ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND  No package.json (or package.yaml, or package.json5) was found in "/Users/debmukherjee/firecrawl".
  •  ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND  No package.json (or package.yaml, or package.json5) was found in "/Users/debmukherjee/firecrawl".

Summary by cubic

Stop sending the Authorization header in @mendable/firecrawl-js for 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

    • API v1/v2: add robotsMode (ignore | respect | strict) and normalize userAgent into headers; strict mode fails closed on robots verification errors and disallowed URLs; derive ignoreRobotsTxt from 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: expose robotsMode and userAgent (included in v2 crawl payload); docs add examples for robots controls and self‑hosted usage without apiKey.
  • Bug Fixes

    • JS SDK v1/v2: normalize apiKey inputs (reject whitespace‑only for cloud, avoid TypeErrors) and only set Authorization when non‑empty; self‑hosted omits Authorization in 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; preserve robotsMode through 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 with shouldFailClosedOnInitialRobotsFetch; add unit test for query‑string case.

Written for commit 38d2ff2. Summary will update on new commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/js-sdk/firecrawl/src/v1/index.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

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.

@debgotwired

Copy link
Copy Markdown
Author

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@cubic-dev-ai cubic-dev-ai Bot Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

Comment thread apps/api/src/controllers/v1/types.ts Resolved
Comment thread apps/api/src/controllers/v1/types.ts Resolved
Comment thread apps/api/src/controllers/v2/types.ts Resolved
Comment thread apps/api/src/controllers/v2/types.ts Resolved
Comment thread apps/api/src/scraper/scrapeURL/index.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/lib/robots-policy.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

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.

@cubic-dev-ai

cubic-dev-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/controllers/v2/crawl.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

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.

@cubic-dev-ai

cubic-dev-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/lib/robots-policy.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

Fixed the two latest cubic findings in commit a3c2eee.

  • The JS robots-filter fallback no longer reparses raw links without a base, so valid relative links are preserved when custom user-agent routing forces the JS path.
  • verifyScrapeRobotsAccess now rethrows abort and cancellation errors instead of swallowing them in respect mode.

Verification run before push:

  • corepack pnpm exec jest --runInBand --verbose src/lib/tests/robots-policy.test.ts src/scraper/WebScraper/tests/link-normalization.test.ts

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@debgotwired

Copy link
Copy Markdown
Author

The two latest helper issues were valid and are fixed in commit 90cc48c.

  • resolveCrawlerLink now rejects non-http(s) schemes instead of treating them as valid normalized crawl targets.
  • resolveCrawlerLink now rejects empty and fragment-only hrefs so they do not become duplicate or self-referential crawl targets on the JS filtering path.

Verification run before push:

  • corepack pnpm exec jest --runInBand --verbose src/scraper/WebScraper/tests/link-normalization.test.ts src/lib/tests/robots-policy.test.ts

@debgotwired

Copy link
Copy Markdown
Author

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:

  • v1 crawl strict robots startup was still keyed off the raw request body instead of the effective crawler options.
  • scrapeURL was still swallowing abort and cancellation errors one layer above verifyScrapeRobotsAccess.
  • the JS crawler robots check was still evaluating the raw discovered href instead of the normalized absolute URL.

Verification run before push:

  • corepack pnpm exec jest --runInBand --verbose src/lib/tests/robots-runtime-policy.test.ts src/lib/tests/robots-policy.test.ts src/scraper/WebScraper/tests/link-normalization.test.ts

This was a preemptive sweep to reduce another round of piecemeal follow-up comments. @cubic-dev-ai please re-run review.

@cubic-dev-ai

cubic-dev-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

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:

  • v1 crawl strict robots startup was still keyed off the raw request body instead of the effective crawler options.
  • scrapeURL was still swallowing abort and cancellation errors one layer above verifyScrapeRobotsAccess.
    ...

@debgotwired I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/js-sdk/firecrawl/src/v1/index.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

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:

  • v1 now normalizes API keys with an explicit string type guard.
  • I proactively applied the same guard to the v2 client and the shared HTTP transport path, since they had the same input-shape risk.
  • Added focused constructor tests covering non-string cloud apiKey inputs for both v1 and v2.

Verification run before push:

  • corepack pnpm exec jest --runInBand --verbose src/tests/unit/v2/clientOptions.test.ts
  • corepack pnpm build

@cubic-dev-ai please re-run review.

@cubic-dev-ai

cubic-dev-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

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:
...

@debgotwired I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/scraper/scrapeURL/index.ts Resolved
Comment thread apps/api/src/controllers/v1/types.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

Both latest reports were valid, and I fixed them in commit 6800793.

  • strict robots verification failures in scrapeURL now return as consistent failed ScrapeUrlResponse values instead of escaping as promise rejections
  • mapRequestSchema now applies the robots normalization transform, so robotsMode correctly derives ignoreRobotsTxt for map requests

I also applied the same map-schema normalization fix in v2 preemptively, since it had the same omission.

Verification run before push:

  • corepack pnpm exec jest --runInBand --verbose src/lib/tests/robots-runtime-policy.test.ts src/tests/snips/v1/types-validation.test.ts src/tests/snips/v2/types-validation.test.ts

@cubic-dev-ai please re-run review.

@cubic-dev-ai

cubic-dev-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Both latest reports were valid, and I fixed them in commit 6800793.

  • strict robots verification failures in scrapeURL now return as consistent failed ScrapeUrlResponse values instead of escaping as promise rejections
  • mapRequestSchema now applies the robots normalization transform, so robotsMode correctly derives ignoreRobotsTxt for map requests

...

@debgotwired I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/scraper/scrapeURL/index.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/scraper/scrapeURL/index.ts Resolved
Comment thread apps/api/src/lib/robots-txt.ts Resolved
@debgotwired

Copy link
Copy Markdown
Author

The latest three reports were valid, and I fixed them in commit c57d581.

What changed:

  • scrapeURL now actually returns the failed ScrapeUrlResponse produced by the robots-check catch path instead of continuing into the scrape loop
  • robots user-agent matching now treats the first explicit match as authoritative, so an exact UA denial is not overridden by a later derived-token allow
  • the JS crawler fallback path now enforces external-link and subdomain policy before robots evaluation, matching the Rust path semantics more closely

Verification run before push:

  • corepack pnpm exec jest --runInBand --verbose src/lib/tests/robots-runtime-policy.test.ts src/lib/tests/robots-txt.test.ts src/scraper/WebScraper/tests/crawl-target-policy.test.ts

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.

@cubic-dev-ai

cubic-dev-ai Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

The latest three reports were valid, and I fixed them in commit c57d581.

What changed:

  • scrapeURL now actually returns the failed ScrapeUrlResponse produced by the robots-check catch path instead of continuing into the scrape loop
  • robots user-agent matching now treats the first explicit match as authoritative, so an exact UA denial is not overridden by a later derived-token allow
    ...

@debgotwired I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/api/src/lib/robots-access.ts Resolved
- 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]>
@debgotwired

Copy link
Copy Markdown
Author

Follow-up pushed in 38d2ff2.

Fixes:

  1. robots-access.ts trailing-slash corruption (cubic P2): The url + "/" fallback now uses URL object pathname manipulation instead of raw string concatenation. https://example.com/page?q=1 correctly becomes https://example.com/page/?q=1 instead of the broken https://example.com/page?q=1/. Unit test added.
  2. Map controller strict-mode consistency (proactive): Both v1/map.ts and map-utils.ts now use shouldFailClosedOnInitialRobotsFetch() instead of direct === "strict" comparison, consistent with crawl controllers.

Re: CrawlOptions serialization comment (cubic P2 on v2/types.ts): This was already addressed — ignoreRobotsTxt and robotsMode are explicitly serialized in prepareCrawlPayload() at apps/js-sdk/firecrawl/src/v2/methods/crawl.ts lines 36-37, with passing unit test in crawl.test.ts.

Requesting re-review.

@capy-ai

capy-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

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.

@capy-ai capy-ai Bot closed this Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant