{"record":{"id":"93e7e3858dbc6d32","repo":"alibaba/open-code-review","slug":"invalid-mcp-server-url-q-w","errorCode":null,"errorMessage":"invalid MCP server URL %q: %w","messagePattern":"invalid MCP server URL %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":891,"sourceCode":"\tcase \"env\":\n\t\tvar env []string\n\t\tif err := json.Unmarshal([]byte(value), &env); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)\n\t\t}\n\t\tfor _, e := range env {\n\t\t\tidx := strings.Index(e, \"=\")\n\t\t\tif idx <= 0 {\n\t\t\t\treturn fmt.Errorf(\"invalid env entry %q: must be in KEY=VALUE format\", e)\n\t\t\t}\n\t\t}\n\t\tentry.Env = env\n\tcase \"url\":\n\t\tif value == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL cannot be empty\")\n\t\t}\n\t\tparsed, err := url.Parse(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid MCP server URL %q: %w\", value, err)\n\t\t}\n\t\tif parsed.Scheme != \"http\" && parsed.Scheme != \"https\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL must use http or https scheme, got %q\", parsed.Scheme)\n\t\t}\n\t\tif parsed.Host == \"\" {\n\t\t\treturn fmt.Errorf(\"MCP server URL %q must include a host\", value)\n\t\t}\n\t\tentry.URL = value\n\tcase \"headers\":\n\t\tparsed, err := parseMCPHeaders(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid headers for %s: %w\", key, err)\n\t\t}\n\t\tentry.Headers = parsed\n\tcase \"tools\":\n\t\tvar tools []string\n\t\tif err := json.Unmarshal([]byte(value), &tools); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON array for %s: %w\", key, err)","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L873-L909","documentation":"Fires when url.Parse fails on the value given for mcp_servers.<name>.url — the string is syntactically not a URL (e.g. contains control characters or a malformed scheme). The raw parse error is wrapped and the invalid value quoted so the user can see which input failed.","triggerScenarios":"Calling setMCPServerValue with field \"url\" and a value that net/url.Parse rejects, e.g. containing raw control characters or invalid percent-escapes like 'http://x/%zz'.","commonSituations":"Pasting URLs with unescaped special characters from terminals or docs; corrupted values from shell escaping of '%' sequences.","solutions":["Percent-encode special characters properly in the URL","Test the URL with a browser or `curl -I` first","Ensure valid percent escapes: %20 not %zz"],"exampleFix":"// before\nocr config set mcp_servers.api.url 'http://host/path%zz'\n// after\nocr config set mcp_servers.api.url 'http://host/path%20x'","handlingStrategy":"validation","validationCode":"if _, err := url.Parse(rawURL); err != nil {\n\treturn fmt.Errorf(\"malformed URL: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := setMCPServerValue(cfg, key, value); err != nil {\n\tfmt.Fprintf(os.Stderr, \"config set failed: %v\\n\", err)\n\tos.Exit(1)\n}","preventionTips":["Percent-encode special characters in the URL","Test the URL with curl or a browser before configuring","Avoid raw control characters when pasting URLs"],"tags":["config","mcp","url","validation"],"backgroundTag":"invalid-url","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}