{"record":{"id":"7ff125043652b339","repo":"chenhg5/cc-connect","slug":"weixin-invalid-proxy-url-q-w","errorCode":null,"errorMessage":"weixin: invalid proxy URL %q: %w","messagePattern":"weixin: invalid proxy URL %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/weixin/weixin.go","lineNumber":216,"sourceCode":"\t\tburstWindow = 0\n\t}\n\n\tdataDir, _ := opts[\"cc_data_dir\"].(string)\n\tproject, _ := opts[\"cc_project\"].(string)\n\tstateDir := \"\"\n\tif dataDir != \"\" && project != \"\" {\n\t\tsafeProj := sanitizePathSegment(project)\n\t\tstateDir = filepath.Join(dataDir, \"weixin\", safeProj, sanitizePathSegment(accountLabel))\n\t}\n\tif override, _ := opts[\"state_dir\"].(string); strings.TrimSpace(override) != \"\" {\n\t\tstateDir = strings.TrimSpace(override)\n\t}\n\n\thttpClient := &http.Client{Timeout: defaultAPITimeout}\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(\"weixin: 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(\"weixin: using proxy\", \"proxy\", u.Redacted())\n\t}\n\n\t// CDN 客户端：微信国内 CDN 必须直连，绕过环境变量中的代理（如 HTTPS_PROXY）\n\tcdnHttpClient := &http.Client{\n\t\tTimeout:   60 * time.Second,\n\t\tTransport: &http.Transport{Proxy: nil},\n\t}\n\n\tif burstLimit <= 0 {\n\t\tburstLimit = defaultBurstLimit","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/weixin/weixin.go#L198-L234","documentation":"New reads the optional \"proxy\" option and parses it with url.Parse before wiring it into the HTTP client. If the proxy string is not a valid URL, construction aborts with this wrapped error naming the offending value.","triggerScenarios":"weixin.New is given opts[\"proxy\"] set to a malformed URL, e.g. \"127.0.0.1:7890\" without a scheme, or a string with illegal characters/spaces.","commonSituations":"Proxy configured without http:// or socks5:// scheme; copied proxy string includes surrounding quotes or whitespace; config value built from env vars that contain invalid characters.","solutions":["Add an explicit scheme to the proxy value, e.g. \"http://127.0.0.1:7890\" or \"socks5://...\"","Trim quotes/whitespace from the configured proxy string","Check the wrapped inner url.Parse error for the exact parse failure position"],"exampleFix":"// before\n\"proxy\": \"127.0.0.1:7890\"\n// after\n\"proxy\": \"http://127.0.0.1:7890\"","handlingStrategy":"validation","validationCode":"if raw, _ := opts[\"proxy\"].(string); raw != \"\" {\n    if _, err := url.Parse(strings.TrimSpace(raw)); err != nil {\n        return fmt.Errorf(\"bad weixin proxy %q: %w\", raw, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"p, err := weixin.New(opts)\nif err != nil && strings.Contains(err.Error(), \"invalid proxy URL\") {\n    return fmt.Errorf(\"fix proxy in config: %w\", err)\n}","preventionTips":["Always include a scheme (http:// or socks5://) in proxy values","Trim quotes/whitespace when interpolating from env vars","Test the proxy with curl before wiring it into config"],"tags":["go","config","proxy","url"],"backgroundTag":"invalid-url-format","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}