{"record":{"id":"24ce3d4c27d91553","repo":"vxcontrol/pentagi","slug":"request-failed-s","errorCode":null,"errorMessage":"request failed: %s","messagePattern":"request failed: (.+?)","errorType":"exception","errorClass":"FatalError","httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/firecrawl.go","lineNumber":183,"sourceCode":"\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", Retryable(fmt.Errorf(\"failed to do request: %v\", err), 0)\n\t}\n\tdefer resp.Body.Close()\n\n\treturn f.parseHTTPResponse(ctx, query, resp)\n}\n\nfunc (f *firecrawl) parseHTTPResponse(ctx context.Context, query string, resp *http.Response) (string, error) {\n\tswitch resp.StatusCode {\n\tcase http.StatusOK:\n\t\tvar respBody firecrawlSearchResult\n\t\tif err := json.NewDecoder(resp.Body).Decode(&respBody); err != nil {\n\t\t\treturn \"\", Fatal(fmt.Errorf(\"failed to decode response body: %v\", err))\n\t\t}\n\t\tif !respBody.Success {\n\t\t\tif respBody.Error != \"\" {\n\t\t\t\treturn \"\", Fatal(fmt.Errorf(\"request failed: %s\", respBody.Error))\n\t\t\t}\n\t\t\treturn \"\", Fatal(fmt.Errorf(\"request failed\"))\n\t\t}\n\t\treturn f.buildFirecrawlResult(ctx, query, &respBody), nil\n\tcase http.StatusBadRequest:\n\t\treturn \"\", Fatal(fmt.Errorf(\"request is invalid\"))\n\tcase http.StatusUnauthorized:\n\t\treturn \"\", Fatal(fmt.Errorf(\"API key is wrong\"))\n\tcase http.StatusPaymentRequired:\n\t\treturn \"\", Fatal(fmt.Errorf(\"insufficient credits to perform this request\"))\n\tcase http.StatusForbidden:\n\t\treturn \"\", Fatal(fmt.Errorf(\"the endpoint requested is hidden for administrators only\"))\n\tcase http.StatusNotFound:\n\t\treturn \"\", Fatal(fmt.Errorf(\"the specified endpoint could not be found\"))\n\tcase http.StatusMethodNotAllowed:\n\t\treturn \"\", Fatal(fmt.Errorf(\"there need to try to access an endpoint with an invalid method\"))\n\tcase http.StatusRequestTimeout:\n\t\treturn \"\", Retryable(fmt.Errorf(\"the request timed out. try again later\"), 0)","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/firecrawl.go#L165-L201","documentation":"Fatal error from the Firecrawl searcher (backend/pkg/tools/searchers/firecrawl.go) returned when the Firecrawl API responds 200 with success=false and a non-empty error string in the body, or plain 'request failed' when no message is given. The search query was rejected by the service; not retryable.","triggerScenarios":"POST /v2/search returns {\"success\":false,\"error\":\"<engine message>\"} — e.g. credits exhausted, job rejected, upstream scrape failure.","commonSituations":"Out of Firecrawl credits/quota on the account, engine-side crawl failure for the query, account suspended.","solutions":["Read the embedded upstream message (%s) for the exact vendor reason.","Check Firecrawl dashboard for credits/quota and billing status.","Retry later if the message indicates transient upstream failure; otherwise switch engines via fallback.","Confirm API key belongs to an active, non-suspended team."],"exampleFix":"// before: ignoring success flag\nvar r firecrawlSearchResult; json.Decode(&r); return r.Data\n// after\nif !r.Success { return \"\", Fatal(fmt.Errorf(\"request failed: %s\", r.Error)) }","handlingStrategy":"fallback","validationCode":"// check account status before heavy usage\ninfo, err := firecrawlClient.CreditUsage(ctx)\nif err == nil && info.Remaining <= 0 { return errors.New(\"firecrawl credits exhausted\") }","typeGuard":"func isUpstreamFailure(res firecrawlSearchResult) bool { return !res.Success }","tryCatchPattern":"res, err := f.parseHTTPResponse(ctx, q, resp)\nif err != nil {\n  if !searchers.IsRetryable(err) { orchestrator.markEngineUnhealthy(f); useFallback(q) }\n}","preventionTips":["Monitor Firecrawl credit/quota usage and alert before exhaustion.","Keep billing/payment method current on the engine account.","Configure fallback engines for graceful degradation.","Surface upstream error text in logs verbatim."],"tags":["api","upstream-error","fatal","firecrawl"],"backgroundTag":"upstream-api-error","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}