{"record":{"id":"a13703333be02830","repo":"chenhg5/cc-connect","slug":"wecom-invalid-api-base-url-q-must-be-a-valid-ht","errorCode":null,"errorMessage":"wecom: invalid api_base_url %q: must be a valid http(s) URL","messagePattern":"wecom: invalid api_base_url %q: must be a valid http\\(s\\) URL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":157,"sourceCode":"\t\treturn nil, fmt.Errorf(\"wecom: invalid callback_aes_key: %w\", err)\n\t}\n\n\tport, _ := opts[\"port\"].(string)\n\tif port == \"\" {\n\t\tport = \"8081\"\n\t}\n\tpath, _ := opts[\"callback_path\"].(string)\n\tif path == \"\" {\n\t\tpath = \"/wecom/callback\"\n\t}\n\tapiBaseURL, _ := opts[\"api_base_url\"].(string)\n\tapiBaseURL = strings.TrimRight(strings.TrimSpace(apiBaseURL), \"/\")\n\tif apiBaseURL == \"\" {\n\t\tapiBaseURL = defaultAPIBaseURL\n\t} else {\n\t\tparsed, err := url.Parse(apiBaseURL)\n\t\tif err != nil || (parsed.Scheme != \"https\" && parsed.Scheme != \"http\") || parsed.Host == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"wecom: invalid api_base_url %q: must be a valid http(s) URL\", apiBaseURL)\n\t\t}\n\t}\n\n\ttransport := &http.Transport{\n\t\tMaxIdleConns:        2,\n\t\tMaxIdleConnsPerHost: 1,\n\t\tIdleConnTimeout:     10 * time.Second,\n\t}\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(\"wecom: 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}","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L139-L175","documentation":"When api_base_url is set in the options, New() parses it and requires scheme http or https plus a non-empty host. Empty or missing api_base_url falls back to the official WeCom API base URL, but a present-but-malformed value aborts construction. This lets deployments point the platform at a proxy or self-hosted gateway while rejecting typos early.","triggerScenarios":"Setting api_base_url to a value like \"qyapi.weixin.qq.com\" (no scheme), \"ftp://host\", \"://host\", or any string that url.Parse rejects, fails to produce scheme http/https, or yields an empty Host.","commonSituations":"Typing the domain without https://; a corporate gateway URL with a typo or trailing path issues; config templating that leaves an invalid placeholder; pointing at a local mock server with a wrong scheme like localhost:8080 without http://.","solutions":["Prefix the value with https:// (e.g. https://qyapi.weixin.qq.com) and ensure a hostname is present","Remove the api_base_url option entirely to use the default official endpoint","Validate the URL with url.Parse in a quick script before putting it in config","Check for template/variable expansion mistakes that leave placeholder text in the value"],"exampleFix":"// before\n\"api_base_url\": \"qyapi.weixin.qq.com\" // no scheme -> invalid api_base_url\n// after\n\"api_base_url\": \"https://qyapi.weixin.qq.com\"","handlingStrategy":"validation","validationCode":"u, _ := opts[\"api_base_url\"].(string)\nif u != \"\" {\n\tif parsed, err := url.Parse(strings.TrimSpace(u)); err != nil || (parsed.Scheme != \"http\" && parsed.Scheme != \"https\") || parsed.Host == \"\" {\n\t\treturn fmt.Errorf(\"api_base_url %q is not a valid http(s) URL\", u)\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the scheme (https://) in base URLs","Leave api_base_url unset unless pointing at a gateway/proxy","Validate URLs in config linting before deployment","Watch for template placeholders that don't expand"],"tags":["wecom","config","url","validation"],"backgroundTag":"invalid-url","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"}