{"record":{"id":"07ed88d56fbfa9a6","repo":"github/copilot-sdk","slug":"invalid-cli-url-format-url","errorCode":null,"errorMessage":"Invalid cli_url format: {url}","messagePattern":"Invalid cli_url format: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/copilot/client.py","lineNumber":1871,"sourceCode":"            ValueError: If the URL format is invalid or the port is out of range.\n        \"\"\"\n        clean_url = re.sub(r\"^https?://\", \"\", url)\n\n        # Check if it's just a port number\n        if clean_url.isdigit():\n            port = int(clean_url)\n            if port <= 0 or port > 65535:\n                raise ValueError(f\"Invalid port in cli_url: {url}\")\n            return (\"localhost\", port)\n\n        ipv6_match = re.match(r\"^\\[([^\\]]+)\\]:(.*)$\", clean_url)\n        if ipv6_match:\n            host = ipv6_match.group(1)\n            port_text = ipv6_match.group(2)\n            try:\n                ipaddress.IPv6Address(host)\n            except ValueError as e:\n                raise ValueError(f\"Invalid cli_url format: {url}\") from e\n        else:\n            # Parse host:port format\n            parts = clean_url.split(\":\")\n            if len(parts) != 2:\n                raise ValueError(f\"Invalid cli_url format: {url}\")\n            host = parts[0] if parts[0] else \"localhost\"\n            port_text = parts[1]\n\n        try:\n            port = int(port_text)\n        except ValueError as e:\n            raise ValueError(f\"Invalid port in cli_url: {url}\") from e\n\n        if port <= 0 or port > 65535:\n            raise ValueError(f\"Invalid port in cli_url: {url}\")\n\n        return (host, port)\n","sourceCodeStart":1853,"sourceCodeEnd":1889,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/python/copilot/client.py#L1853-L1889","documentation":"This ValueError is raised when the host portion of a bracketed IPv6 cli_url is not a valid IPv6 address. The parser matches `[#]...` and validates the host with `ipaddress.IPv6Address(host)`; a ValueError there is re-raised as this error. It ensures malformed IPv6 literals fail fast with a clear message.","triggerScenarios":"Passing cli_url like 'http://[zz::1]:4242', 'http://[abc]:8080', or 'http://[]:4242' — bracketed text that is not parseable as IPv6.","commonSituations":"Hand-edited config files with malformed IPv6 literals; missing the brackets and writing 'http://::1:4242' which the parser misreads; environment-specific URLs copy-pasted incorrectly.","solutions":["Use a valid bracketed IPv6 URL, e.g. cli_url='http://[::1]:4242'.","Or use an IPv4/hostname form like 'http://localhost:4242'.","Validate the URL with `ipaddress.IPv6Address()` before passing it in."],"exampleFix":"// before\nclient = CopilotClient(cli_url=\"http://[zz::1]:4242\")\n// after\nclient = CopilotClient(cli_url=\"http://[::1]:4242\")","handlingStrategy":"validation","validationCode":"import ipaddress, re\nm = re.match(r\"^\\[([^\\]]+)\\]\", re.sub(r\"^https?://\", \"\", url))\nif m:\n    ipaddress.IPv6Address(m.group(1))  # raises before client construction","typeGuard":null,"tryCatchPattern":"try:\n    client = CopilotClient(cli_url=url)\nexcept ValueError as e:\n    if \"Invalid cli_url format\" in str(e):\n        raise ConfigError(f\"malformed cli_url: {url}\") from e\n    raise","preventionTips":["Always bracket IPv6 literals in URLs: http://[::1]:port","Test URLs with ipaddress.IPv6Address before deploying config","Use hostnames where possible to avoid IPv6 literal mistakes"],"tags":["python","config","url-parsing","ipv6"],"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"}