{"record":{"id":"4b5c4458b62890ba","repo":"rtk-ai/rtk","slug":"invalid-ctest-summary-regex","errorCode":null,"errorMessage":"invalid ctest summary regex","messagePattern":"invalid ctest summary regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":42,"sourceCode":"static 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+:\")\n        .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,\n    reason: Option<String>,\n    duration: f64,\n    line_index: usize,\n    counter_total: Option<u32>,\n}\n\n#[derive(Debug)]","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/system/ctest_cmd.rs#L24-L60","documentation":"This is a panic from `.expect(\"invalid ctest summary regex\")` on `Regex::new` inside the SUMMARY_RE LazyLock static at src/cmds/system/ctest_cmd.rs:42. SUMMARY_RE parses ctest's `NNN% tests passed, N tests failed out of N` summary line to extract failure counts. The panic indicates the pattern literal is no longer a parseable regex; it surfaces on first use of the static while filtering ctest output.","triggerScenarios":"First pass of ctest output through the filter after SUMMARY_RE's pattern `^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)` was edited into invalid syntax — unbalanced group, bad escape such as `\\%`-style mistakes, or a missing quantifier operand.","commonSituations":"Extending the summary parser for new ctest formats (editing the pattern and losing a paren), escaping confusion when a raw string is changed, or a partial revert/merge that mixes two versions of the literal.","solutions":["Inspect the SUMMARY_RE literal at src/cmds/system/ctest_cmd.rs:42-43 and fix the regex parse error","Validate the corrected pattern with regex101 (Rust flavor) or a quick unit test","Restore the known-good pattern: r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\"","Run the full gate: cargo fmt --all && cargo clippy --all-targets && cargo test --all"],"exampleFix":"// before (dropped closing paren on second capture group)\nRegex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+\")\n    .expect(\"invalid ctest summary regex\")\n// after\nRegex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\")\n    .expect(\"invalid ctest summary regex\")","handlingStrategy":"validation","validationCode":"fn assert_summary_regex_valid() {\n    assert!(regex::Regex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\").is_ok());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test the summary parser against recorded ctest summary fixtures","Avoid mixing pattern-format upgrades and refactors in one commit","Add a one-line is_ok() assertion per regex static to the test suite","Always use raw strings for regex literals in Rust"],"tags":["regex","panic","summary-parsing","ctest"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"36788f6bd4932037caac5cbb1d15d6e2fb9f33da","analyzedAt":"2026-09-03T16:33:57.738Z","contentChangedAt":"2026-09-03T16:33:57.738Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}