{"record":{"id":"c63a0e5a45482cfd","repo":"vxcontrol/pentagi","slug":"failed-to-build-request-v","errorCode":null,"errorMessage":"failed to build request: %v","messagePattern":"failed to build request: (.+?)","errorType":"exception","errorClass":"FatalError","httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/firecrawl.go","lineNumber":158,"sourceCode":"\t// sources is intentionally omitted: /v2/search defaults to [\"web\"], which is\n\t// all this tool consumes, and it avoids the string-vs-object shape ambiguity\n\t// that field carries across the API/SDK layers.\n\treqPayload := firecrawlRequest{\n\t\tQuery: query,\n\t\tLimit: maxResults,\n\t\tScrapeOptions: &firecrawlScrapeOptions{\n\t\t\tFormats:         []string{\"markdown\"},\n\t\t\tOnlyMainContent: true,\n\t\t},\n\t}\n\treqBody, err := json.Marshal(reqPayload)\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to marshal request body: %v\", err))\n\t}\n\n\treq, err := http.NewRequest(http.MethodPost, f.searchURL(), bytes.NewBuffer(reqBody))\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to build request: %v\", err))\n\t}\n\n\treq = req.WithContext(ctx)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Authorization\", \"Bearer \"+f.apiKey())\n\n\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:","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/firecrawl.go#L140-L176","documentation":"Fatal error from the Firecrawl searcher's Handle (backend/pkg/tools/searchers/firecrawl.go) when http.NewRequest fails while building the POST search request. Practically only occurs with an invalid configured FIRCRAWL server URL. Retry will not help until configuration is fixed.","triggerScenarios":"searchURL() produces a malformed URL (e.g. empty or invalid SERVER_URL / base path with control characters or bad percent-encoding).","commonSituations":"Misconfigured Firecrawl server URL env var (spaces, missing scheme, typo like 'htp://'), empty config making the URL invalid.","solutions":["Print/log f.searchURL() and fix the configured base URL (must include scheme).","Validate the URL with url.Parse in a quick test before deployment.","Set the Firecrawl server URL to a canonical https:// value in env/settings.","Ensure no control characters or raw spaces are interpolated into the URL."],"exampleFix":"// before\nFIRECRAWL_SERVER_URL=firecrawl.dev/v2  # missing scheme\n// after\nFIRECRAWL_SERVER_URL=https://api.firecrawl.dev/v2","handlingStrategy":"validation","validationCode":"u, err := url.Parse(cfg.ServerURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n  return fmt.Errorf(\"invalid firecrawl server url: %q\", cfg.ServerURL)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the https:// scheme in server URL config.","Validate URL config at startup, not at request time.","Avoid string concatenation into URLs; use url.Values/path joins."],"tags":["http","url","configuration","firecrawl"],"backgroundTag":"invalid-url","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}