fix(search): relay API error messages for every search, not only Alexandria ones

Merged
NI
4d ago
+25-15

firecrawl_search only routed errors through relayExchangeError when sources included alexandria. When an agent passed its own non-Alexandria sources (["web"], ["news"], ...), the call went through relayTermsRequired, which rethrows the raw axios error from client.http.post. The agent then saw Request failed with status code 402 with the API's out-of-credits message and upgrade link stripped. Default searches and scrapes were unaffected because they already used relayExchangeError or the SDK's own error normalization.

  • Both search entry points (src/server.ts and the hosted src/service/search-surface.ts) now always use relayExchangeError, which still handles the terms-required case and still leaves 401s to credential recovery.
  • The fallback message for an error body without an error string now says Firecrawl request failed (HTTP N) instead of Alexandria request failed, since it is no longer Alexandria-only.
  • New test: a 402 with the API's credits message is relayed verbatim for default, ["web"], ["news"] and ["alexandria"] searches. It failed before the fix with the bare axios message.

No version bump or changelog entry; leaving that to the release.

Open in Capy


Summary by cubic

Fixes firecrawl_search error handling so non-Alexandria searches (e.g. ["web"], ["news"]) surface the API's actual error message. Previously these went through relayTermsRequired, which rethrew the raw axios error — a 402 showed only "Request failed with status code 402" and dropped the out-of-credits message and upgrade link. Version 3.30.2 is bumped with a changelog entry for the fix.

  • Both search entry points (src/server.ts and src/service/search-surface.ts) now always use relayExchangeError, which still handles the terms-required case.
  • The fallback message for an error body without an error string now reads Firecrawl request failed (HTTP N) instead of Alexandria request failed.
  • New test verifies a 402 with the API's credits message is relayed verbatim for default, ["web"], ["news"], and ["alexandria"] searches.