{"record":{"id":"04218aef6037cce2","repo":"github/copilot-sdk","slug":"uriconnection-requires-a-non-empty-url","errorCode":null,"errorMessage":"URIConnection requires a non-empty URL","messagePattern":"URIConnection requires a non-empty URL","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":274,"sourceCode":"\t}\n\tswitch conn := connection.(type) {\n\tcase StdioConnection:\n\t\tclient.useStdio = true\n\t\tclient.cliPath = conn.Path\n\t\tif len(conn.Args) > 0 {\n\t\t\tclient.cliArgs = append([]string{}, conn.Args...)\n\t\t}\n\tcase TCPConnection:\n\t\tclient.useStdio = false\n\t\tclient.cliPath = conn.Path\n\t\tif len(conn.Args) > 0 {\n\t\t\tclient.cliArgs = append([]string{}, conn.Args...)\n\t\t}\n\t\tclient.port = conn.Port\n\t\tclient.tcpConnectionToken = conn.ConnectionToken\n\tcase URIConnection:\n\t\tif conn.URL == \"\" {\n\t\t\tpanic(\"URIConnection requires a non-empty URL\")\n\t\t}\n\t\thost, port := parseCLIURL(conn.URL)\n\t\tclient.actualHost = host\n\t\tclient.actualPort = port\n\t\tclient.isExternalServer = true\n\t\tclient.useStdio = false\n\t\tclient.tcpConnectionToken = conn.ConnectionToken\n\tcase InProcessConnection:\n\t\tclient.useStdio = false\n\t\tclient.useInProcess = true\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown RuntimeConnection type: %T\", connection))\n\t}\n\n\t// Validate transport-specific option constraints (fail loud). The in-process\n\t// transport loads the runtime into this process, whose single environment\n\t// block, process-global working directory, and shared telemetry state cannot\n\t// carry per-client values. Child-process transports may set env via either","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L256-L292","documentation":"NewClient panics when a URIConnection is supplied with an empty URL. A URIConnection means 'attach to an already-running external runtime at this address', so without a URL there is nothing to connect to and construction cannot proceed.","triggerScenarios":"Calling NewClient with Connection: clientpkg.URIConnection{URL: \"\"} — typically because the URL comes from a config value or env var that is unset or empty. Panic at go/client.go:274.","commonSituations":"Environment variable like COPILOT_CLI_URL is not set and its value is passed straight into URIConnection; wiring an external-server option that was left blank in YAML/flags.","solutions":["Provide a valid URL, e.g. URIConnection{URL: \"http://127.0.0.1:4141\"}.","Check the config/env source for the URL and fail earlier with a clear message if empty.","If no external server exists, use the default connection (StdioConnection) instead."],"exampleFix":"// before\nclient := clientpkg.NewClient(&clientpkg.Options{\n    Connection: clientpkg.URIConnection{URL: os.Getenv(\"COPILOT_CLI_URL\")}, // empty\n})\n// after\nu := os.Getenv(\"COPILOT_CLI_URL\")\nif u == \"\" {\n    u = \"http://127.0.0.1:4141\"\n}\nclient := clientpkg.NewClient(&clientpkg.Options{\n    Connection: clientpkg.URIConnection{URL: u},\n})","handlingStrategy":"validation","validationCode":"if conn.URL == \"\" {\n    return fmt.Errorf(\"URIConnection.URL is required\")\n}\nif _, err := url.Parse(conn.URL); err != nil {\n    return fmt.Errorf(\"invalid URIConnection.URL: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the env var/config value feeding the URL for emptiness before constructing the client.","Provide a sensible default URL for local external servers.","Validate all connection settings in one config-validation pass."],"tags":["go","panic","url","connection","validation"],"backgroundTag":"empty-required-field","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"}