{"record":{"id":"f4e2ed222493cfb2","repo":"rtk-ai/rtk","slug":"invalid-ctest-start-regex","errorCode":null,"errorMessage":"invalid ctest start regex","messagePattern":"invalid ctest start regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":38,"sourceCode":"// 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+:\")\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,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/system/ctest_cmd.rs#L20-L56","documentation":"This is a panic from `.expect(\"invalid ctest start regex\")` on `Regex::new` inside the START_RE LazyLock static at src/cmds/system/ctest_cmd.rs:38. START_RE matches `Start N: <test name>` lines emitted by ctest; an invalid pattern makes rtk panic on first use instead of silently producing wrong output. It is a programmer error in the pattern literal, not a runtime/input problem.","triggerScenarios":"The first time the ctest filter processes output after START_RE's pattern `^\\s*Start\\s+(\\d+):\\s*(.*?)\\s*$` was corrupted — e.g. an unclosed capture group `(`, a repetition operator with nothing to repeat (`*?` at pattern start), or an invalid unicode escape.","commonSituations":"Renaming the capture group or adding a new group and leaving an unbalanced paren, converting the raw string to a normal string so `\\s` becomes an unknown escape, or manual conflict resolution dropping one `)` from the line.","solutions":["Open src/cmds/system/ctest_cmd.rs around line 38 and fix the START_RE pattern syntax","Balance-check parentheses and escapes in the literal; validate on regex101 (Rust flavor)","Restore the known-good pattern: r\"^\\s*Start\\s+(\\d+):\\s*(.*?)\\s*$\"","Add a #[test] that asserts Regex::new(PATTERN).is_ok() for each ctest static to catch this at CI time"],"exampleFix":"// before (unclosed capture group)\nRegex::new(r\"^\\s*Start\\s+(\\d+:\\s*(.*?)\\s*$\").expect(\"invalid ctest start regex\")\n// after\nRegex::new(r\"^\\s*Start\\s+(\\d+):\\s*(.*?)\\s*$\").expect(\"invalid ctest start regex\")","handlingStrategy":"validation","validationCode":"fn assert_start_regex_valid() {\n    assert!(regex::Regex::new(r\"^\\s*Start\\s+(\\d+):\\s*(.*?)\\s*$\").is_ok());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Count opening/closing parens whenever adding or renaming capture groups","Use a regex lint/clippy pass or editor plugin that highlights unbalanced groups","Snapshot-test START_RE against real `ctest -V` start lines","Keep each regex static on its own lines so diffs isolate pattern changes"],"tags":["regex","panic","capture-group","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-14T05:17:10.506Z"}