{"record":{"id":"8a966dc8b34bf794","repo":"github/copilot-sdk","slug":"failed-to-parse-port-w","errorCode":null,"errorMessage":"failed to parse port: %w","messagePattern":"failed to parse port: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/client.go","lineNumber":2246,"sourceCode":"\t\t\t\t}\n\t\t\t\treturn errors.Join(baseErr, killErr)\n\t\t\tcase <-c.processDone:\n\t\t\t\tkillErr := c.killProcess()\n\t\t\t\tbaseErr := errors.New(\"CLI server process exited before reporting port\")\n\t\t\t\tif buf, ok := proc.Stderr.(*truncbuffer.TruncBuffer); ok {\n\t\t\t\t\tif stderr := strings.TrimSpace(buf.String()); stderr != \"\" {\n\t\t\t\t\t\tbaseErr = fmt.Errorf(\"%w; stderr: %s\", baseErr, stderr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn errors.Join(baseErr, killErr)\n\t\t\tdefault:\n\t\t\t\tif scanner.Scan() {\n\t\t\t\t\tline := scanner.Text()\n\t\t\t\t\tif matches := portRegex.FindStringSubmatch(line); len(matches) > 1 {\n\t\t\t\t\t\tport, err := strconv.Atoi(matches[1])\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tkillErr := c.killProcess()\n\t\t\t\t\t\t\treturn errors.Join(fmt.Errorf(\"failed to parse port: %w\", err), killErr)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tc.actualPort = port\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n// startInProcess loads the native runtime library and wires the JSON-RPC client\n// to its FFI byte streams.\nfunc (c *Client) startInProcess(ctx context.Context) error {\n\tif !inProcessAvailable {\n\t\treturn errors.New(\"in-process transport unavailable: rebuild with -tags copilot_inprocess on a supported platform\")\n\t}\n\n\tcliEntrypoint := c.cliPath","sourceCodeStart":2228,"sourceCodeEnd":2264,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/client.go#L2228-L2264","documentation":"The CLI server printed a line matching the port regex, but the captured number could not be converted to an integer via strconv.Atoi. This is an internal invariant violation: the regex matched something that is not a valid Go int (e.g. overflow or malformed digits), and the process is killed before returning.","triggerScenarios":"The CLI printed a port-like token that fails Atoi — port number exceeding int range, empty/near-empty match, or a regex that matched more of the line than intended.","commonSituations":"Version mismatch where a new CLI version changed its stdout port-report format; locale/formatting changes in CLI output; 32-bit platforms where large ports overflow int.","solutions":["Check CLI and client library versions match; upgrade the library to support the CLI's current port format.","Capture the offending stdout line (enable debug logging) to see what the regex matched.","If on a 32-bit platform, test on 64-bit or report the overflow.","File an issue with the stdout line if the CLI output looks correct."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to parse port\") {\n        return fmt.Errorf(\"CLI/client version mismatch on port handshake: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep the CLI binary and client library versions aligned.","Watch for CLI upgrades that change stdout handshake output.","Enable debug logging of the process stdout during incidents.","Report matched-but-unparseable output to maintainers with the raw line."],"tags":["process","parsing","port","protocol-mismatch"],"backgroundTag":"unexpected-response-shape","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"}