chenhg5/cc-connect · error
discord: invalid proxy URL %q: %w
Error message
discord: invalid proxy URL %q: %w
What it means
The Discord adapter parses the optional "proxy" option as a URL at construction time; if url.Parse fails, New wraps and returns the parse error together with the offending string. This catches syntactically invalid proxy URLs before any connection is attempted.
Source
Thrown at platform/discord/discord.go:122
progressStyle := "compact"
if v, ok := opts["progress_style"].(string); ok {
switch strings.ToLower(strings.TrimSpace(v)) {
case "":
// keep default
case "legacy":
progressStyle = "legacy"
case "compact", "card":
progressStyle = strings.ToLower(strings.TrimSpace(v))
default:
return nil, fmt.Errorf("discord: invalid progress_style %q (want legacy, compact, or card)", v)
}
}
var proxyU *url.URL
if proxyStr, _ := opts["proxy"].(string); proxyStr != "" {
u, err := url.Parse(proxyStr)
if err != nil {
return nil, fmt.Errorf("discord: invalid proxy URL %q: %w", proxyStr, err)
}
if user, _ := opts["proxy_username"].(string); user != "" {
pass, _ := opts["proxy_password"].(string)
u.User = url.UserPassword(user, pass)
}
proxyU = u
}
base := &Platform{
token: token,
allowFrom: allowFrom,
guildID: guildID,
progressStyle: progressStyle,
groupReplyAllGuilds: groupReplyAllGuilds,
shareSessionInChannel: shareSessionInChannel,
readyCh: make(chan struct{}),
threadIsolation: threadIsolation,
respondToAtEveryoneAndHere: respondToAtEveryoneAndHere,View on GitHub (pinned to 4000b2338a)
Solutions
- Fix the proxy URL in the discord platform config so it parses, e.g. "http://127.0.0.1:7890" or "socks5://user:pass@host:1080".
- Percent-encode special characters (spaces, %, non-ASCII) in the URL.
- Remove the proxy option if no proxy is needed.
- Test the string first with a quick url.Parse in Go or a URI validator to see the exact parse error.
Example fix
// before proxy = "127.0.0.1:7890::socks" // after proxy = "socks5://127.0.0.1:7890"
Defensive patterns
Strategy: validation
Validate before calling
if v, _ := opts["proxy"].(string); v != "" {
if _, err := url.Parse(v); err != nil {
log.Fatalf("invalid discord proxy URL %q: %v", v, err)
}
} Try / catch
p, err := discord.New(opts)
if err != nil && strings.Contains(err.Error(), "invalid proxy URL") {
log.Fatalf("fix proxy option: %v", err)
} Prevention
- Always include the scheme in proxy URLs (http:// or socks5://)
- Avoid raw spaces and special characters; percent-encode when needed
- Verify the proxy string with url.Parse or curl before deploying
- Keep proxy settings per-environment in validated config templates
When it happens
Trigger: Calling discord.New(opts) where opts["proxy"] is a string that url.Parse rejects — e.g. "http://[bad-ipv6", "::9090" (ambiguous colon), or control characters in the URL.
Common situations: Hand-edited config.toml with a malformed proxy address; missing scheme combined with stray colons; copied proxy URL containing spaces or hidden characters; env-specific proxy injected with wrong format.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- providerproxy: parse target: %w
- discord: token is required
- discord: invalid progress_style %q (want legacy, compact, or
- telegram: invalid proxy URL %q: %w
- wecom: invalid proxy URL %q: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/7c7ec7274366898a.
Report an issue: GitHub.