wavetermdev/waveterm · error
invalid proxy URL: %w
Error message
invalid proxy URL: %w
What it means
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).
Source
Thrown at pkg/aiusechat/aiutil/aiutil.go:200
encoder.SetEscapeHTML(false)
err := encoder.Encode(reqBody)
if err != nil {
return buf, err
}
return buf, nil
}
func MakeHTTPClient(proxyURL string) (*http.Client, error) {
client := &http.Client{
Timeout: 0, // rely on ctx; streaming can be long
}
if proxyURL == "" {
return client, nil
}
pURL, err := url.Parse(proxyURL)
if err != nil {
return nil, fmt.Errorf("invalid proxy URL: %w", err)
}
client.Transport = &http.Transport{
Proxy: http.ProxyURL(pURL),
}
return client, nil
}
func IsOpenAIReasoningModel(model string) bool {
m := strings.ToLower(model)
return CheckModelPrefix(m, "o1") ||
CheckModelPrefix(m, "o3") ||
CheckModelPrefix(m, "o4") ||
CheckModelPrefix(m, "gpt-5") ||
CheckModelSubPrefix(m, "gpt-5.") ||
CheckModelPrefix(m, "gpt-6") ||
CheckModelSubPrefix(m, "gpt-6.")
}
View on GitHub (pinned to a4447c1563)
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.
Example fix
// before
client, err := aiutil.MakeHTTPClient("http://proxy myhost:8080") // invalid
// after
client, err := aiutil.MakeHTTPClient("http://myhost:8080") Defensive patterns
Strategy: validation
Validate before calling
func validateProxy(u string) error {
if u == "" { return nil }
if _, err := url.Parse(u); err != nil { return fmt.Errorf("bad proxy %q: %w", u, err) }
return nil
}
// run at config-load time Try / catch
client, err := aiutil.MakeHTTPClient(proxy)
if err != nil {
return nil, fmt.Errorf("check your proxy configuration: %w", err)
} Prevention
- 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
When it happens
Trigger: 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".
Common situations: 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.
Related errors
- No tab view found for the given webContents id
- cannot call ${methodName}: no web endpoint
- ai:model is required
- chatOpts.ClientId is required
- ai:endpoint is required
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/436e06c27e9c766b.
Report an issue: GitHub.