{"record":{"id":"fad8ada5ae86f1a7","repo":"github/copilot-sdk","slug":"invalid-uriconnection-format-s","errorCode":null,"errorMessage":"Invalid URIConnection format: %s","messagePattern":"Invalid URIConnection format: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":421,"sourceCode":"// parseCLIURL parses a CLI URL into host and port components.\n//\n// Supports formats: \"host:port\", \"[ipv6]:port\", \"http://host:port\", \"https://host:port\", or just \"port\".\n// Panics if the URL format is invalid or the port is out of range.\nfunc parseCLIURL(url string) (string, int) {\n\t// Remove protocol if present\n\tcleanURL, _ := strings.CutPrefix(url, \"https://\")\n\tcleanURL, _ = strings.CutPrefix(cleanURL, \"http://\")\n\n\t// Use the standard parser only for the bracketed IPv6 form. Keep the\n\t// existing host:port parsing behavior for all other inputs.\n\tif strings.HasPrefix(cleanURL, \"[\") {\n\t\thost, portStr, err := net.SplitHostPort(cleanURL)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Invalid port in URIConnection: %s\", url))\n\t\t}\n\t\taddr, err := netip.ParseAddr(host)\n\t\tif err != nil || !addr.Is6() {\n\t\t\tpanic(fmt.Sprintf(\"Invalid URIConnection format: %s\", url))\n\t\t}\n\t\tport, err := strconv.Atoi(portStr)\n\t\tif err != nil || port <= 0 || port > 65535 {\n\t\t\tpanic(fmt.Sprintf(\"Invalid port in URIConnection: %s\", url))\n\t\t}\n\t\treturn host, port\n\t}\n\n\t// Parse host:port or port format\n\tvar host string\n\tvar portStr string\n\tif before, after, found := strings.Cut(cleanURL, \":\"); found {\n\t\thost = before\n\t\tportStr = after\n\t} else {\n\t\tportStr = cleanURL\n\t}\n","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L403-L439","documentation":"parseCLIURL in go/client.go parses the URIConnection URL passed to NewClient. When the URL looks like a bracketed host:port ([v6]:port) it validates that the host is a valid IPv6 address; if netip.ParseAddr fails or the address is not IPv6, it panics with this message. The library only accepts IPv6 literal hosts in the bracketed form, so any other host form here is rejected.","triggerScenarios":"Calling NewClient with a CLI URL like \"http://[hostname]:3000\" or \"[::1:notanumber]\" where SplitHostPort succeeds (bracketed form) but the host inside brackets is not a valid IPv6 literal (e.g. a DNS name, IPv4, or malformed address).","commonSituations":"Developers put a hostname or IPv4 address inside brackets instead of an IPv6 literal, or hand-build the URL string with typos (missing/extra colons), or an environment variable containing the server URL was set to a non-IPv6 bracketed value.","solutions":["Use an IPv6 literal inside brackets, e.g. \"http://[::1]:3000\"","Use the plain host:port form without brackets for IPv4/hostname, e.g. \"http://localhost:3000\"","Pass only a port (e.g. \":3000\" or the port string) to default to localhost","Log/print the exact URL string before NewClient to spot bracket or colon mistakes"],"exampleFix":"// before\nclient := NewClient(\"http://[myhost]:3000\")\n// after\nclient := NewClient(\"http://localhost:3000\") // or \"http://[::1]:3000\" for IPv6","handlingStrategy":"validation","validationCode":"func validCLIURL(u string) bool {\n\thost, port, err := net.SplitHostPort(u)\n\tif err != nil {\n\t\treturn false\n\t}\n\tif strings.HasPrefix(u, \"[\") {\n\t\taddr, err := netip.ParseAddr(host)\n\t\treturn err == nil && addr.Is6()\n\t}\n\t_, err = strconv.Atoi(port)\n\treturn err == nil\n}","typeGuard":"func isIPv6Literal(host string) bool {\n\taddr, err := netip.ParseAddr(host)\n\treturn err == nil && addr.Is6()\n}","tryCatchPattern":null,"preventionTips":["Never put hostnames or IPv4 inside brackets; brackets are only for IPv6 literals","Prefer plain host:port URLs like http://localhost:PORT","Sanitize environment-provided URLs before passing to NewClient","Write a table test covering IPv6, IPv4, hostname, and port-only forms"],"tags":["go","url-parsing","ipv6","panic"],"backgroundTag":"invalid-url-format","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}