{"record":{"id":"ef6af64e5dc14530","repo":"chenhg5/cc-connect","slug":"telegram-invalid-proxy-url-q-w","errorCode":null,"errorMessage":"telegram: invalid proxy URL %q: %w","messagePattern":"telegram: invalid proxy URL %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/telegram/telegram.go","lineNumber":152,"sourceCode":"\tstableConnectionWindow  = 10 * time.Second\n)\n\nfunc New(opts map[string]any) (core.Platform, error) {\n\ttoken, _ := opts[\"token\"].(string)\n\tif token == \"\" {\n\t\treturn nil, fmt.Errorf(\"telegram: token is required\")\n\t}\n\tallowFrom, _ := opts[\"allow_from\"].(string)\n\tcore.CheckAllowFrom(\"telegram\", allowFrom)\n\n\t// Build HTTP client with optional proxy support.\n\t// Timeout must exceed the server-side long-poll duration (pollTimeout − 1s = 59s)\n\t// to avoid the HTTP client racing with Telegram's response. 90s gives 30s headroom.\n\thttpClient := &http.Client{Timeout: 90 * time.Second}\n\tif proxyURL, _ := opts[\"proxy\"].(string); proxyURL != \"\" {\n\t\tu, err := url.Parse(proxyURL)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"telegram: invalid proxy URL %q: %w\", proxyURL, err)\n\t\t}\n\t\tproxyUser, _ := opts[\"proxy_username\"].(string)\n\t\tproxyPass, _ := opts[\"proxy_password\"].(string)\n\t\tif proxyUser != \"\" {\n\t\t\tu.User = url.UserPassword(proxyUser, proxyPass)\n\t\t}\n\t\thttpClient.Transport = &http.Transport{Proxy: http.ProxyURL(u)}\n\t\tslog.Info(\"telegram: using proxy\", \"proxy\", u.Host, \"auth\", proxyUser != \"\")\n\t}\n\n\tgroupReplyAll, _ := opts[\"group_reply_all\"].(bool)\n\tshareSessionInChannel, _ := opts[\"share_session_in_channel\"].(bool)\n\tenableReactions, _ := opts[\"enable_reactions\"].(bool)\n\n\t// Default to \"compact\" so streaming edits work out of the box. Telegram has\n\t// no rich card UI, so \"card\" is normalized to \"compact\". Users can opt out\n\t// via progress_style = \"legacy\" to restore the old \"send full text once\"\n\t// behavior.","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/telegram/telegram.go#L134-L170","documentation":"telegram.New() parses the optional 'proxy' option as a URL. If url.Parse rejects the value, construction fails with this error wrapping the parse error, because a malformed proxy address would break every subsequent HTTP request to the Telegram API.","triggerScenarios":"Calling telegram.New(opts) with opts[\"proxy\"] set to a string that url.Parse cannot parse, e.g. \"http://[bad-ipv6\", \"::1:8080\", or a value with stray control characters / spaces.","commonSituations":"Proxy URL copied with surrounding quotes or whitespace into config.toml; missing scheme confusion; hand-edited config introducing invalid characters; IPv6 proxy not bracketed correctly.","solutions":["Fix the proxy URL in config, e.g. proxy = \"socks5://127.0.0.1:1080\" or \"http://proxy:8080\"","Bracket IPv6 hosts: \"http://[::1]:8080\"","Read the wrapped %w parse error to see the exact offending character","Remove the proxy option entirely if no proxy is needed"],"exampleFix":"// before\nproxy = \"127.0.0.1:1080\"\n# after\nproxy = \"socks5://127.0.0.1:1080\"","handlingStrategy":"validation","validationCode":"if raw := opts[\"proxy\"]; raw != \"\" {\n    if _, err := url.Parse(raw); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"p, err := telegram.New(opts)\nif err != nil {\n    slog.Error(\"telegram init failed (check proxy URL)\", \"err\", err)\n    return err\n}","preventionTips":["Test the proxy URL with url.Parse or curl before putting it in config","Bracket IPv6 hosts and include the scheme (http://, socks5://)","Strip quotes/whitespace when copying proxy values into config"],"tags":["telegram","proxy","url","config"],"backgroundTag":"invalid-url","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}