{"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":"error","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":41,"sourceCode":"\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,\n    reason: Option<String>,\n    duration: f64,\n    line_index: usize,\n    counter_total: Option<u32>,\n}\n\n#[derive(Debug)]","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/system/ctest_cmd.rs#L23-L59","documentation":"Panic from the .expect() guarding SUMMARY_RE in src/cmds/system/ctest_cmd.rs, which extracts pass/fail counts from ctest's 'N% tests passed, M tests failed out of T' summary line. The regex is compiled lazily in a LazyLock static; invalid syntax panics with this message at first filter use rather than surfacing an error. It is an internal invariant — the shipped pattern is valid and end users should never hit it.","triggerScenarios":"First access of SUMMARY_RE while summarizing ctest output, if the pattern in the source was edited into an invalid form (unbalanced parenthesis, invalid escape).","commonSituations":"Regex typo during a filter change; partially applied patch/merge to the statics block; regex crate version incompatibility.","solutions":["Correct the regex syntax in the SUMMARY_RE literal in src/cmds/system/ctest_cmd.rs","Validate with `cargo test ctest` or a one-off Regex::new test","Use `rtk proxy ctest ...` to get unfiltered ctest output as a workaround","Rebuild: `cargo build`"],"exampleFix":"// before\nRegex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\").expect(\"invalid ctest summary regex\")\n// after (restore the missing closing group)\nRegex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\").expect(\"invalid ctest summary regex\")","handlingStrategy":"validation","validationCode":"assert!(regex::Regex::new(r\"^\\s*\\d+%\\s+tests passed,\\s+(\\d+)\\s+tests failed out of\\s+(\\d+)\").is_ok(), \"SUMMARY_RE must compile\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cover SUMMARY_RE in a snapshot/unit test with real ctest summary lines","Run cargo clippy + cargo test after editing regexes","Avoid duplicating the pattern in multiple places","Bypass with `rtk proxy ctest ...` if needed"],"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"}