{"record":{"id":"2cb986c8492c984c","repo":"vxcontrol/pentagi","slug":"failed-to-build-request-v-2cb986","errorCode":null,"errorMessage":"failed to build request: %v","messagePattern":"failed to build request: (.+?)","errorType":"exception","errorClass":"Fatal","httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/traversaal.go","lineNumber":88,"sourceCode":"\nfunc (t *traversaal) search(ctx context.Context, query string) (string, error) {\n\tclient, err := system.GetHTTPClient(t.cfg)\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to create http client: %w\", err))\n\t}\n\n\treqBody, err := json.Marshal(struct {\n\t\tQuery string `json:\"query\"`\n\t}{\n\t\tQuery: query,\n\t})\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, traversaalURL, 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(\"x-api-key\", t.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 t.parseHTTPResponse(resp)\n}\n\nfunc (t *traversaal) parseHTTPResponse(resp *http.Response) (string, error) {\n\tif resp.StatusCode != http.StatusOK {\n\t\terr := fmt.Errorf(\"unexpected status code: %d\", resp.StatusCode)","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/traversaal.go#L70-L106","documentation":"traversaal.search returns Fatal 'failed to build request: %v' when http.NewRequest(http.MethodPost, traversaalURL, ...) fails. NewRequest errors on an invalid method or an unparseable URL, so this means the traversaalURL constant/config is malformed — a deployment/build-time problem, not a runtime network issue.","triggerScenarios":"http.NewRequest returns err because traversaalURL (or its configured override) is not a valid absolute URL (e.g. missing scheme, control characters, bad host).","commonSituations":"Misconfigured TRAVERSAAL server URL env var with spaces or missing https://; a fork pointing traversaalURL at an empty or placeholder value; config substitution injecting invalid characters.","solutions":["Read the wrapped error; NewRequest reports url.Parse failures precisely.","Verify the Traversaal base URL env var is a valid absolute https:// URL.","Validate the URL at startup (url.Parse) so bad config fails fast.","If traversaalURL is hardcoded, check the constant wasn't corrupted by edits."],"exampleFix":"// before: placeholder left in env\nTRAVERSAAL_SERVER_URL=your-api-key-here\n// after: valid endpoint\nTRAVERSAAL_SERVER_URL=https://api.traversaal.ai/hybrid/live","handlingStrategy":"validation","validationCode":"if u, err := url.Parse(traversaalURL); err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid traversaal URL: %q\", traversaalURL)\n}","typeGuard":null,"tryCatchPattern":"result, err := traversaalSearcher.Handle(ctx, req)\nvar f *searchers.FatalError\nif errors.As(err, &f) && strings.Contains(f.Error(), \"failed to build request\") {\n    return \"\", fmt.Errorf(\"check TRAVERSAAL server URL config: %w\", err)\n}","preventionTips":["Validate the endpoint URL with url.Parse at searcher construction","Require absolute https:// URLs in configuration; reject placeholders","Fail fast at boot if the configured URL is empty or malformed"],"tags":["http","traversaal","url","config"],"backgroundTag":"invalid-request-url","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}