{"record":{"id":"b142a171f6a8c0f1","repo":"github/copilot-sdk","slug":"invalid-port-in-cliurl-url","errorCode":null,"errorMessage":"Invalid port in cliUrl: ${url}","messagePattern":"Invalid port in cliUrl: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/client.ts","lineNumber":775,"sourceCode":"        const cleanUrl = url.replace(/^https?:\\/\\//, \"\");\n\n        // Check if it's just a port number\n        if (/^\\d+$/.test(cleanUrl)) {\n            return { host: \"localhost\", port: parseInt(cleanUrl, 10) };\n        }\n\n        // Handle the canonical bracketed IPv6 host:port form without changing\n        // the existing parser behavior for other inputs.\n        const ipv6Match = cleanUrl.match(/^\\[([^\\]]+)\\]:(\\d+)$/);\n        if (ipv6Match) {\n            const host = ipv6Match[1];\n            if (!isIPv6(host)) {\n                throw new Error(`Invalid cliUrl format: ${url}`);\n            }\n\n            const port = parseInt(ipv6Match[2], 10);\n            if (isNaN(port) || port <= 0 || port > 65535) {\n                throw new Error(`Invalid port in cliUrl: ${url}`);\n            }\n            return { host, port };\n        }\n\n        // Parse host:port format\n        const parts = cleanUrl.split(\":\");\n        if (parts.length !== 2) {\n            throw new Error(\n                `Invalid cliUrl format: ${url}. Expected \"host:port\", \"[ipv6]:port\", \"http://host:port\", or \"port\"`\n            );\n        }\n\n        const host = parts[0] || \"localhost\";\n        const port = parseInt(parts[1], 10);\n\n        if (isNaN(port) || port <= 0 || port > 65535) {\n            throw new Error(`Invalid port in cliUrl: ${url}`);\n        }","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/client.ts#L757-L793","documentation":"parseCliUrl extracted a port from the bracketed IPv6 form but parseInt produced NaN or a value outside 1-65535. The cliUrl string's port segment is syntactically numeric but semantically not a usable TCP port.","triggerScenarios":"Thrown at nodejs/src/client.ts:775 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a port in the range 1-65535, e.g. '[::1]:8080'","Check for leading zeros, embedded whitespace, or copy-paste artifacts like colons duplicated in the port segment","If the port comes from configuration, validate it before constructing the cliUrl string"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}