{"record":{"id":"98934c38cfcabb16","repo":"vxcontrol/pentagi","slug":"request-failed","errorCode":null,"errorMessage":"request failed","messagePattern":"request failed","errorType":"exception","errorClass":"FatalError","httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/firecrawl.go","lineNumber":185,"sourceCode":"\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)\n\tcase http.StatusTooManyRequests:\n\t\treturn \"\", Retryable(fmt.Errorf(\"there are requesting too many results\"), 0)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/firecrawl.go#L167-L203","documentation":"When the decoded 200-body has success=false but an empty Error field, firecrawl still cannot produce results and returns the bare Fatal 'request failed'. It is a catch-all for an unsuccessful but undescribed engine response.","triggerScenarios":"Firecrawl returns HTTP 200 with {\"success\":false} and no error text — contract violation or empty job result path.","commonSituations":"New/changed Firecrawl API version emitting a different failure shape, self-hosted instance returning bare failures, proxy stripping the error field.","solutions":["Check the Firecrawl API version supported by this codebase vs your instance; align versions.","Log the full response body to capture fields the struct may be missing.","If self-hosted, upgrade the Firecrawl instance to a version matching /v2 semantics.","Use a fallback engine while investigating."],"exampleFix":"// before: struct misses new fields\nError string `json:\"error\"`\n// after\ncodec, _ := io.ReadAll(resp.Body); log.Debugf(\"raw: %s\", codec) // inspect real shape, then extend struct","handlingStrategy":"fallback","validationCode":"// verify engine contract with a probe query\nvar probe firecrawlSearchResult\nif err := json.NewDecoder(resp.Body).Decode(&probe); err == nil && !probe.Success && probe.Error == \"\" {\n  return errors.New(\"engine contract violation: success=false without error\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Firecrawl instance and client on compatible versions.","Log full response bodies for success=false-with-no-error cases.","Add contract tests against a recorded golden response.","Fall back to another engine rather than retrying a contract violation."],"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"}