{"record":{"id":"98b9187451597fe0","repo":"cilium/cilium","slug":"invalid-exit-code-q-in-error-s","errorCode":null,"errorMessage":"invalid exit code %q in error %s","messagePattern":"invalid exit code %q in error (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cilium-cli/connectivity/check/action.go","lineNumber":477,"sourceCode":"\t\ti, err := strconv.Atoi(m[1])\n\t\tif err != nil || i < 1 || i > 255 {\n\t\t\tcontinue\n\t\t}\n\t\treturn ExitCode(i), true\n\t}\n\treturn ExitInvalidCode, false\n}\n\n// extractExitCode extracts command exit code from ExecInPod() error output\nfunc (a *Action) extractExitCode(err error) (ExitCode, error) {\n\t// Extract exit code from 'err'\n\tm := exitCodeRegex.FindStringSubmatch(err.Error())\n\tif len(m) != 2 || len(m[1]) == 0 {\n\t\treturn ExitInvalidCode, fmt.Errorf(\"unable to extract exit code from error: %s\", err.Error())\n\t}\n\ti, err := strconv.Atoi(m[1])\n\tif err != nil {\n\t\treturn ExitInvalidCode, fmt.Errorf(\"invalid exit code %q in error %s\", m[1], err.Error())\n\t}\n\tif i < 0 || i > 255 {\n\t\treturn ExitInvalidCode, fmt.Errorf(\"exit code %q out of range [0-255]\", m[1])\n\t}\n\treturn ExitCode(i), nil\n}\n\n// expectedExitCode returns the expected shell exit code, or ExitAnyError for any value between 1-255.\nfunc (a *Action) expectedExitCode() ExitCode {\n\tif a.expEgress.ExitCode == 0 && a.expIngress.ExitCode == 0 {\n\t\treturn 0 // success\n\t}\n\t// If egress and ingress expect the command to fail in different\n\t// ways egress enforcement will cause the command to fail first.\n\tif a.expEgress.ExitCode != 0 {\n\t\treturn a.expEgress.ExitCode\n\t}\n\treturn a.expIngress.ExitCode","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/cilium-cli/connectivity/check/action.go#L459-L495","documentation":"Raised by extractExitCode when the regex matched a substring but strconv.Atoi cannot parse it as an integer — practically unreachable with a numeric regex, but guards against malformed matches. Returns ExitInvalidCode.","triggerScenarios":"The regex captured group m[1] contains non-numeric text while still being non-empty, during ExecInPod result processing.","commonSituations":"Custom/patched cilium-cli builds with a modified exitCodeRegex; unexpected error string formats from exec infrastructure.","solutions":["Verify your cilium-cli build is unmodified (exitCodeRegex matches 'exit status <int>')","Report the raw error string upstream if it appears in a stock build","Re-run the connectivity test to see if it is transient"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func (a *Action) extractExitCode(err error) (ExitCode, error) {\n    m := exitCodeRegex.FindStringSubmatch(err.Error())\n    if len(m) != 2 || len(m[1]) == 0 {\n        return ExitInvalidCode, fmt.Errorf(\"unable to extract exit code from error: %s\", err.Error())\n    }\n    i, convErr := strconv.Atoi(m[1])\n    if convErr != nil {\n        return ExitInvalidCode, convErr // typed sentinel for callers\n    }\n    return ExitCode(i), nil\n}","tryCatchPattern":"code, err := a.extractExitCode(err)\nif code == ExitInvalidCode {\n    // do not use code for pass/fail; surface raw err instead\n    return err\n}","preventionTips":["Use unmodified cilium-cli builds (stock exitCodeRegex)","Log raw error strings when outcome parsing fails","Treat ExitInvalidCode as 'unknown outcome', never as failure or success"],"tags":["exit-code","exec","parsing","cilium"],"backgroundTag":"exit-code-unparseable","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}