{"record":{"id":"bcdd8e7903ce12be","repo":"vxcontrol/pentagi","slug":"failed-to-create-http-client-w-bcdd8e","errorCode":null,"errorMessage":"failed to create http client: %w","messagePattern":"failed to create http client: %w","errorType":"exception","errorClass":"Fatal","httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/tavily.go","lineNumber":106,"sourceCode":"\t\t\tlangfuse.WithEventMetadata(langfuse.Metadata{\n\t\t\t\t\"engine\":      \"tavily\",\n\t\t\t\t\"query\":       req.Query,\n\t\t\t\t\"max_results\": req.MaxResults,\n\t\t\t\t\"error\":       err.Error(),\n\t\t\t}),\n\t\t)\n\n\t\tobs.LogErrorOrCancel(logger, err, \"failed to search in tavily\")\n\t\treturn \"\", err\n\t}\n\n\treturn result, nil\n}\n\nfunc (t *tavily) search(ctx context.Context, query string, maxResults int) (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\treqPayload := tavilyRequest{\n\t\tQuery:             query,\n\t\tApiKey:            t.apiKey(),\n\t\tTopic:             \"general\",\n\t\tSearchDepth:       \"advanced\",\n\t\tIncludeImages:     false,\n\t\tIncludeAnswer:     true,\n\t\tIncludeRawContent: true,\n\t\tMaxResults:        maxResults,\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, tavilyURL, bytes.NewBuffer(reqBody))","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/tavily.go#L88-L124","documentation":"The Tavily searcher calls system.GetHTTPClient(t.cfg) to build its outbound HTTP client; failure (invalid proxy URL, bad TLS config) yields a Fatal error with no retry. Identical in nature to the Sploitus client-creation error — it reflects environment/config, not the Tavily API.","triggerScenarios":"tavily.search() (called from Handle) invokes system.GetHTTPClient(t.cfg) before building the request; fails when cfg has an unparsable proxy or invalid transport/TLS options.","commonSituations":"Invalid HTTP_PROXY/HTTPS_PROXY URL in the container environment, nonexistent or malformed CA bundle configured for the proxy, or corrupted config after editing .env/docker-compose.","solutions":["Fix the proxy URL named in the wrapped error (scheme required, e.g. http://host:port)","Validate custom CA bundle path/PEM content referenced by the config","Test with proxies unset to isolate whether proxy config is the cause"],"exampleFix":"// before\nHTTPS_PROXY=socks://bad host:1080\n// after\nHTTPS_PROXY=socks5://proxy.internal:1080","handlingStrategy":"validation","validationCode":"if proxy := os.Getenv(\"HTTPS_PROXY\"); proxy != \"\" {\n    if _, err := url.Parse(proxy); err != nil {\n        log.Fatalf(\"invalid HTTPS_PROXY %q: %v\", proxy, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"client, err := system.GetHTTPClient(t.cfg)\nif err != nil {\n    return \"\", Fatal(fmt.Errorf(\"failed to create http client: %w\", err))\n}","preventionTips":["Validate proxy and TLS config at startup before any search runs","Keep .env and docker-compose proxy settings consistent","Smoke-test outbound HTTPS to api.tavily.com in the deployment check"],"tags":["http-client","proxy","tls","go"],"backgroundTag":"invalid-proxy-configuration","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}