sipeed/picoclaw · error

invalid discord proxy URL %q: %w

Error message

invalid discord proxy URL %q: %w

What it means

applyDiscordProxy failed to url.Parse the configured discord proxy address (%q prints the exact string); the parse error is wrapped with %w. It fires at channel construction, so the Discord channel never starts. Almost always the address lacks a scheme — url.Parse requires one for a usable proxy URL.

Source

Thrown at pkg/channels/discord/discord.go:776

	ext := strings.ToLower(filepath.Ext(filename))
	switch ext {
	case ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp":
		return "image"
	case ".mp3", ".wav", ".ogg", ".m4a", ".flac", ".aac", ".wma":
		return "audio"
	case ".mp4", ".avi", ".mov", ".webm", ".mkv":
		return "video"
	}

	return "file"
}

func applyDiscordProxy(session *discordgo.Session, proxyAddr string) error {
	var proxyFunc func(*http.Request) (*url.URL, error)
	if proxyAddr != "" {
		proxyURL, err := url.Parse(proxyAddr)
		if err != nil {
			return fmt.Errorf("invalid discord proxy URL %q: %w", proxyAddr, err)
		}
		proxyFunc = http.ProxyURL(proxyURL)
	} else if os.Getenv("HTTP_PROXY") != "" || os.Getenv("HTTPS_PROXY") != "" {
		proxyFunc = http.ProxyFromEnvironment
	}

	if proxyFunc == nil {
		return nil
	}

	transport := &http.Transport{Proxy: proxyFunc}
	session.Client = &http.Client{
		Timeout:   sendTimeout,
		Transport: transport,
	}

	if session.Dialer != nil {
		dialerCopy := *session.Dialer

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Add the scheme: http://127.0.0.1:7890, https://..., or socks5://127.0.0.1:7890
  2. Trim whitespace/newlines from the config value
  3. Alternatively unset discord.proxy and use HTTP_PROXY/HTTPS_PROXY env vars, which applyDiscordProxy also honors

Example fix

# before
channels:
  discord:
    proxy: "127.0.0.1:7890"

# after
channels:
  discord:
    proxy: "socks5://127.0.0.1:7890"
Defensive patterns

Strategy: validation

Validate before calling

func validProxyURL(addr string) error {
    if addr == "" {
        return nil
    }
    u, err := url.Parse(strings.TrimSpace(addr))
    if err != nil {
        return fmt.Errorf("invalid discord proxy URL %q: %w", addr, err)
    }
    if u.Scheme == "" || u.Host == "" {
        return fmt.Errorf("proxy URL %q needs a scheme (http/https/socks5) and host", addr)
    }
    return nil
}

Prevention

When it happens

Trigger: Setting discord.proxy to 'host:port' (e.g. '127.0.0.1:7890') without an http:// or socks5:// scheme, stray whitespace/quotes, or a trailing newline from an env-sourced config value.

Common situations: Copying the proxy address from a GUI client that displays it without scheme, config templating that injects whitespace, switching between HTTP and SOCKS proxies.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/23aeaa1071b77f81. Report an issue: GitHub.