{"record":{"id":"e3d2428ab86ad81f","repo":"vxcontrol/pentagi","slug":"failed-to-create-http-client-w-e3d242","errorCode":null,"errorMessage":"failed to create http client: %w","messagePattern":"failed to create http client: %w","errorType":"exception","errorClass":"FatalError","httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/searchers/perplexity.go","lineNumber":139,"sourceCode":"\t\t\t\t\"engine\": \"perplexity\",\n\t\t\t\t\"query\":  req.Query,\n\t\t\t\t\"model\":  p.model(),\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 perplexity\")\n\t\treturn \"\", err\n\t}\n\n\treturn result, nil\n}\n\n// search performs a request to Perplexity API\nfunc (p *perplexity) search(ctx context.Context, query string) (string, error) {\n\tclient, err := system.GetHTTPClient(p.cfg)\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to create http client: %w\", err))\n\t}\n\n\tclient.Timeout = p.timeout()\n\n\t// Creating message for the request\n\tmessages := []Message{\n\t\t{\n\t\t\tRole:    \"user\",\n\t\t\tContent: query,\n\t\t},\n\t}\n\n\t// Forming the request\n\treqPayload := CompletionRequest{\n\t\tMessages:               messages,\n\t\tModel:                  p.model(),\n\t\tSearchContextSize:      p.contextSize(),\n\t\tMaxTokens:              p.maxTokens(),","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/perplexity.go#L121-L157","documentation":"The Perplexity searcher builds its HTTP client via `system.GetHTTPClient(p.cfg)`. If that helper fails (typically invalid proxy configuration — malformed URL, unsupported scheme, bad TLS material), the error is wrapped as a Fatal typed error at backend/pkg/tools/searchers/perplexity.go:139 before any request is sent.","triggerScenarios":"`Handle` → `search` is invoked while `p.cfg` carries an unparseable proxy/TLS setting that `system.GetHTTPClient` rejects — e.g. PERPLEXITY (or global) proxy env var set to `http://[bad` or an unreadable CA file path.","commonSituations":"Malformed HTTP_PROXY/HTTPS_PROXY values; self-signed CA bundle path wrong in container; proxy scheme typo (socks5 unsupported by builder); config parsed from .env with stray whitespace/quotes.","solutions":["Check the wrapped cause — GetHTTPClient's error names the bad setting (proxy URL or CA file)","Fix the proxy env var / config value (valid absolute URL, reachable host) and restart the backend","Remove the proxy setting entirely if no proxy is required to reach api.perplexity.ai","If using a custom CA, verify the file exists inside the container and is valid PEM"],"exampleFix":"// before\nHTTPS_PROXY=\"http://proxy host:3128\" // invalid: space in host\n// after\nHTTPS_PROXY=\"http://proxy-host:3128\"","handlingStrategy":"validation","validationCode":"// validate proxy config before starting the engine\nif proxy := os.Getenv(\"HTTPS_PROXY\"); proxy != \"\" {\n    if _, err := url.Parse(proxy); err != nil || strings.ContainsAny(proxy, \" \\t\") {\n        return fmt.Errorf(\"invalid HTTPS_PROXY: %q\", proxy)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := engine.Handle(ctx, req)\nif err != nil && searchers.IsFatal(err) && strings.Contains(err.Error(), \"failed to create http client\") {\n    // config problem: fix proxy/TLS settings, do not retry\n}","preventionTips":["Validate proxy URLs at config-load time (url.Parse + scheme check)","Verify custom CA bundle paths exist and are valid PEM inside the container","Avoid stray whitespace/quotes in .env proxy values","Smoke-test GetHTTPClient in a startup health check"],"tags":["http-client","proxy","configuration"],"backgroundTag":"invalid-proxy-configuration","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}