{"record":{"id":"106fb3c8f02c32c2","repo":"gofiber/fiber","slug":"client-invalid-proxy-url-w","errorCode":null,"errorMessage":"client: invalid proxy URL: %w","messagePattern":"client: invalid proxy URL: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/client.go","lineNumber":369,"sourceCode":"\t\tc.logger.Panicf(\"client: %v\", ErrFailedToAppendCert)\n\t}\n\n\treturn c\n}\n\n// SetProxyURL sets the proxy URL for the client. This affects all subsequent requests.\nfunc (c *Client) SetProxyURL(proxyURL string) error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\t// Build the fasthttp proxy dialer directly so invalid proxy URLs are returned\n\t// to callers instead of being swallowed by FasthttpHTTPDialer.\n\tdialer := fasthttpproxy.Dialer{\n\t\tConfig: httpproxy.Config{HTTPProxy: proxyURL, HTTPSProxy: proxyURL},\n\t}\n\tdialFunc, err := dialer.GetDialFunc(false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"client: invalid proxy URL: %w\", err)\n\t}\n\tc.applyDial(dialFunc)\n\treturn nil\n}\n\n// RetryConfig returns a copy of the current retry configuration.\nfunc (c *Client) RetryConfig() *RetryConfig {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\n\tif c.retryConfig == nil {\n\t\treturn nil\n\t}\n\n\tcfg := *c.retryConfig\n\treturn &cfg\n}\n","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/client/client.go#L351-L387","documentation":"SetProxyURL builds a fasthttpproxy dialer from the supplied URL and returns this error when GetDialFunc rejects it. The cause is the underlying proxy parse error (bad scheme, unresolvable host, invalid port, unsupported scheme).","triggerScenarios":"Calling client.SetProxyURL with a malformed string: missing scheme (\"127.0.0.1:1080\"), unsupported scheme (\"socks5://\" when fasthttpproxy cannot configure it), empty string in some configs, or a URL with invalid characters.","commonSituations":"Reading the proxy URL from an env var that is unset or has stray whitespace; a config typo; switching from HTTP to SOCKS proxy without the right scheme prefix; copy-pasting a cURL-style proxy string.","solutions":["Prefix the proxy URL with a supported scheme (http://, https://, socks5://).","Trim and validate the URL with url.Parse before calling SetProxyURL; reject empty values.","Log the wrapped cause — it names the exact parse failure (scheme/port/host)."],"exampleFix":"// before\nif err := c.SetProxyURL(os.Getenv(\"HTTP_PROXY\")); err != nil { ... }\n\n// after\nproxy := strings.TrimSpace(os.Getenv(\"HTTP_PROXY\"))\nif _, err := url.Parse(proxy); err != nil {\n    return fmt.Errorf(\"bad HTTP_PROXY: %w\", err)\n}\nif err := c.SetProxyURL(proxy); err != nil { ... }","handlingStrategy":"validation","validationCode":"proxy := strings.TrimSpace(os.Getenv(\"HTTP_PROXY\"))\nif proxy == \"\" { /* proceed without proxy */ }\nu, err := url.Parse(proxy)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\" && u.Scheme != \"socks5\") {\n    return fmt.Errorf(\"invalid proxy URL %q\", proxy)\n}\nreturn c.SetProxyURL(proxy)","typeGuard":null,"tryCatchPattern":"if err := c.SetProxyURL(proxy); err != nil {\n    return fmt.Errorf(\"startup config: bad proxy: %w\", err)\n}","preventionTips":["Always include the scheme (http://, socks5://) in proxy URLs.","Read proxy config from a single validated source; fail fast at startup, not per-request.","Trim whitespace from env-supplied URLs."],"tags":["client","proxy","url-parsing","config"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}