{"record":{"id":"ae835d8a420a00e9","repo":"rtk-ai/rtk","slug":"invalid-ctest-result-terminator-regex","errorCode":null,"errorMessage":"invalid ctest result terminator regex","messagePattern":"invalid ctest result terminator regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":34,"sourceCode":"const MAX_FAILURE_HEAD_LINES: usize = 2;\nconst MAX_FAILED_LIST_LINES: usize = CAP_LIST;\nconst MAX_DETECT_PREAMBLE_LINES: usize = 4;\n// Failure entries carry a header plus up to `MAX_FAILURE_LINES` detail lines each,\n// so this list deviates below `CAP_LIST`; the single-line skipped and raw-trailer\n// lists keep the full cap.\nconst MAX_FAILED_BLOCK_ENTRIES: usize = truncate::reduced(CAP_LIST, 5);\n\nstatic TEST_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(\n        r\"(?s)^\\s*(?:\\d+/(\\d+)\\s+)?Test\\s+#(\\d+):\\s+(.+?)\\s+\\.{2,}\\s*(?:\\*{3})?\\s*(.+?)\\s+([\\d.]+)\\s+sec\\s*$\",\n    )\n    .expect(\"invalid ctest result regex\")\n});\nstatic RESULT_PREFIX_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*(?:\\d+/\\d+\\s+)?Test\\s+#\\d+:\").expect(\"invalid ctest result prefix regex\")\n});\nstatic RESULT_TERMINATOR_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"[\\d.]+\\s+sec\\s*$\").expect(\"invalid ctest result terminator regex\")\n});\nstatic START_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*Start\\s+(\\d+):\\s*(.*?)\\s*$\").expect(\"invalid ctest start regex\")\n});\nstatic SUMMARY_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\")\n        .expect(\"invalid ctest summary regex\")\n});\nstatic TIME_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"^\\s*Total Test time \\(real\\)\\s+=\\s+([\\d.]+)\\s+sec\")\n        .expect(\"invalid ctest time regex\")\n});\n\n#[derive(Debug, Clone)]\nstruct TestCase {\n    number: u32,\n    name: String,\n    status: String,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/system/ctest_cmd.rs#L16-L52","documentation":"Panic from the .expect() guarding RESULT_TERMINATOR_RE in src/cmds/system/ctest_cmd.rs, the regex matching the trailing '<duration> sec' that marks the end of a ctest result line. Like all rtk filter regexes it compiles lazily on first use; an invalid pattern panics with this message rather than returning Result. It is an internal invariant: the shipped pattern `r\"[\\d.]+\\s+sec\\s*$\"` is valid, so the panic only fires on corrupted/edited source builds.","triggerScenarios":"First access of RESULT_TERMINATOR_RE while filtering ctest output, if a source modification introduced invalid regex syntax (unbalanced character class, invalid escape).","commonSituations":"Hand-edited regex typo in the ctest filter; merge conflict resolved with a partially deleted pattern; regex crate version change altering accepted syntax.","solutions":["Inspect the RESULT_TERMINATOR_RE literal in src/cmds/system/ctest_cmd.rs and fix any regex syntax error","Add/run a unit test that touches the static (`cargo test ctest`) to confirm compilation","Use `rtk proxy ctest ...` as a workaround to get raw ctest output without the filter","Rebuild the binary after fixing: `cargo build`"],"exampleFix":"// before\nRegex::new(r\"[\\d.]+\\s+sec\\s*$\").expect(\"invalid ctest result terminator regex\")\n// after (corrected class if it was broken, e.g. missing bracket)\nRegex::new(r\"[\\d.]+\\s+sec\\s*$\").expect(\"invalid ctest result terminator regex\")","handlingStrategy":"validation","validationCode":"assert!(regex::Regex::new(r\"[\\d.]+\\s+sec\\s*$\").is_ok(), \"RESULT_TERMINATOR_RE must compile\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unit-test each LazyLock regex static at least once","Never hand-edit character classes without running cargo test","Pin the regex crate version to avoid syntax drift","Use `rtk proxy ctest ...` to bypass the filter"],"tags":["rust","regex","panic","ctest"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}