{"record":{"id":"436e06c27e9c766b","repo":"wavetermdev/waveterm","slug":"invalid-proxy-url-w","errorCode":null,"errorMessage":"invalid proxy URL: %w","messagePattern":"invalid proxy URL: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/aiusechat/aiutil/aiutil.go","lineNumber":200,"sourceCode":"\tencoder.SetEscapeHTML(false)\n\terr := encoder.Encode(reqBody)\n\tif err != nil {\n\t\treturn buf, err\n\t}\n\treturn buf, nil\n}\n\nfunc MakeHTTPClient(proxyURL string) (*http.Client, error) {\n\tclient := &http.Client{\n\t\tTimeout: 0, // rely on ctx; streaming can be long\n\t}\n\tif proxyURL == \"\" {\n\t\treturn client, nil\n\t}\n\n\tpURL, err := url.Parse(proxyURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid proxy URL: %w\", err)\n\t}\n\tclient.Transport = &http.Transport{\n\t\tProxy: http.ProxyURL(pURL),\n\t}\n\treturn client, nil\n}\n\nfunc IsOpenAIReasoningModel(model string) bool {\n\tm := strings.ToLower(model)\n\treturn CheckModelPrefix(m, \"o1\") ||\n\t\tCheckModelPrefix(m, \"o3\") ||\n\t\tCheckModelPrefix(m, \"o4\") ||\n\t\tCheckModelPrefix(m, \"gpt-5\") ||\n\t\tCheckModelSubPrefix(m, \"gpt-5.\") ||\n\t\tCheckModelPrefix(m, \"gpt-6\") ||\n\t\tCheckModelSubPrefix(m, \"gpt-6.\")\n}\n","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/aiusechat/aiutil/aiutil.go#L182-L218","documentation":"MakeHTTPClient configures an http.Client with an optional proxy. It throws this error when the supplied proxyURL cannot be parsed by net/url.Parse. Note url.Parse is lenient, so this usually means a truly malformed URL (control characters, invalid percent-encoding, unparseable scheme).","triggerScenarios":"Calling MakeHTTPClient (via RunAnthropicChatStep/RunGeminiChatStep/RunOpenAIChatStep/RunChatStep) with a proxy URL string that url.Parse rejects — e.g. containing raw control characters or invalid escape sequences like \"http://proxy:%zz\".","commonSituations":"Misconfigured proxy settings in config files or environment (WAVE_AI_PROXY-style settings); typos in the proxy address; copy-pasted proxies with embedded whitespace/control characters; IPv6 literals unbracketed in some contexts.","solutions":["Fix the proxy URL string to a valid absolute URL, e.g. \"http://host:port\" or \"socks5://host:port\".","Check the wrapped url.Parse error (errors.Unwrap / %w chain) for the exact parse failure.","URL-encode any special characters in the userinfo portion (use url.UserPassword).","Clear the proxy setting to run without a proxy if one is not required.","Pre-validate with url.Parse in your config-loading code and fail fast with a clear message."],"exampleFix":"// before\nclient, err := aiutil.MakeHTTPClient(\"http://proxy myhost:8080\") // invalid\n// after\nclient, err := aiutil.MakeHTTPClient(\"http://myhost:8080\")","handlingStrategy":"validation","validationCode":"func validateProxy(u string) error {\n    if u == \"\" { return nil }\n    if _, err := url.Parse(u); err != nil { return fmt.Errorf(\"bad proxy %q: %w\", u, err) }\n    return nil\n}\n// run at config-load time","typeGuard":null,"tryCatchPattern":"client, err := aiutil.MakeHTTPClient(proxy)\nif err != nil {\n    return nil, fmt.Errorf(\"check your proxy configuration: %w\", err)\n}","preventionTips":["Validate proxy URLs when loading config, not at request time","Use well-formed absolute URLs: scheme://host:port; bracket IPv6 hosts","Avoid raw control characters/whitespace; URL-encode userinfo","Allow clearing the proxy setting to fall back to direct connection"],"tags":["proxy","configuration","url-parsing"],"backgroundTag":"invalid-proxy-url","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}