github/copilot-sdk · error

Invalid cliUrl format

Error message

Invalid cliUrl format: ${url}. Expected "host:port", "[ipv6]:port", "http://host:port", or "port"

What it means

Terminal fallback of parseCliUrl: the input matched none of the accepted shapes (bare port, bracketed IPv6, host:port with a valid port). This generic guard fires after all specific parsing branches fail, so the fault is the overall cliUrl string format — typically a missing port, extra slashes, or a scheme the regex does not strip.

Solutions

  1. Reformat the cliUrl as 'host:port' (e.g. 'localhost:8080'), '[ipv6]:port', 'http://host:port', or a bare port number
  2. Ensure a port is actually present — a bare hostname without ':port' is rejected
  3. Trim whitespace and remove stray protocol/suffix characters before passing the value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nodejs/src/client.ts:783 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/60a97827c05761c2. Report an issue: GitHub.

Appendix: source

Thrown at nodejs/src/client.ts:783

        // the existing parser behavior for other inputs.
        const ipv6Match = cleanUrl.match(/^\[([^\]]+)\]:(\d+)$/);
        if (ipv6Match) {
            const host = ipv6Match[1];
            if (!isIPv6(host)) {
                throw new Error(`Invalid cliUrl format: ${url}`);
            }

            const port = parseInt(ipv6Match[2], 10);
            if (isNaN(port) || port <= 0 || port > 65535) {
                throw new Error(`Invalid port in cliUrl: ${url}`);
            }
            return { host, port };
        }

        // Parse host:port format
        const parts = cleanUrl.split(":");
        if (parts.length !== 2) {
            throw new Error(
                `Invalid cliUrl format: ${url}. Expected "host:port", "[ipv6]:port", "http://host:port", or "port"`
            );
        }

        const host = parts[0] || "localhost";
        const port = parseInt(parts[1], 10);

        if (isNaN(port) || port <= 0 || port > 65535) {
            throw new Error(`Invalid port in cliUrl: ${url}`);
        }

        return { host, port };
    }

    private validateSessionFsConfig(config: SessionFsConfig): void {
        if (!config.initialCwd) {
            throw new Error("sessionFs.initialCwd is required");
        }

View on GitHub (pinned to cd8cf15dc3)