{"record":{"id":"b1bad92cab107cf2","repo":"vxcontrol/pentagi","slug":"failed-to-create-http-client-w-b1bad9","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/sploitus.go","lineNumber":125,"sourceCode":"\n// search calls the Sploitus API and returns a formatted markdown result string\nfunc (s *sploitus) search(ctx context.Context, query, exploitType, sort string, limit int) (string, error) {\n\treqBody := sploitusRequest{\n\t\tQuery:  query,\n\t\tType:   exploitType,\n\t\tSort:   sort,\n\t\tTitle:  false, // search only for titles\n\t\tOffset: 0,\n\t}\n\n\tbodyBytes, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to marshal request body: %w\", err))\n\t}\n\n\tclient, err := system.GetHTTPClient(s.cfg)\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to create http client: %w\", err))\n\t}\n\n\tclient.Timeout = sploitusRequestTimeout\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, sploitusAPIURL, bytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\treturn \"\", Fatal(fmt.Errorf(\"failed to create request: %w\", err))\n\t}\n\n\t// Build referer with query to mimic browser behavior\n\treferer := fmt.Sprintf(\"https://sploitus.com/?query=%s\", url.QueryEscape(query))\n\n\t// Mimic Chrome browser headers to bypass Cloudflare protection\n\treq.Header.Set(\"Accept\", \"application/json\")\n\treq.Header.Set(\"Accept-Language\", \"en-US,en;q=0.9\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"Origin\", \"https://sploitus.com\")\n\treq.Header.Set(\"Referer\", referer)","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/searchers/sploitus.go#L107-L143","documentation":"system.GetHTTPClient(s.cfg) builds the outbound HTTP client from the searcher config (proxy/TLS settings); when construction fails the searcher returns a Fatal error and gives up without retrying. GetHTTPClient typically fails on invalid proxy configuration or bad TLS material.","triggerScenarios":"Handle() on the Sploitus searcher calls system.GetHTTPClient(s.cfg) after marshaling the body; it fails when cfg contains an unparsable proxy URL or malformed TLS/transport options.","commonSituations":"HTTP_PROXY/HTTPS_PROXY env vars contain an invalid URL (e.g. missing scheme), a custom CA file configured for the container does not exist or is not valid PEM, or proxy credentials are malformed.","solutions":["Check the wrapped error for 'unknown scheme' or 'proxy' wording and fix the proxy URL in env/config (HTTP_PROXY, HTTPS_PROXY, NO_PROXY)","Validate any custom CA bundle path referenced by the config exists and contains valid PEM certificates","Unset proxy variables to confirm the error disappears, then re-add them one by one"],"exampleFix":"// before\nexport HTTP_PROXY=\"proxy.corp.local:8080\" // missing scheme\n// after\nexport HTTP_PROXY=\"http://proxy.corp.local:8080\"","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(s.cfg)\nif err != nil {\n    return \"\", Fatal(fmt.Errorf(\"failed to create http client: %w\", err))\n}","preventionTips":["Validate proxy URLs at container startup, not per request","Check CA bundle paths exist and are valid PEM before deploy","Smoke-test outbound HTTPS (curl https://api.example.com) in CI/container entrypoint"],"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"}