{"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":"critical","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":35,"sourceCode":"const 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+:\")\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,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/cmds/system/ctest_cmd.rs#L17-L53","documentation":"This is a panic from `.expect(\"invalid ctest result terminator regex\")` on `Regex::new` inside the RESULT_TERMINATOR_RE LazyLock static at src/cmds/system/ctest_cmd.rs:35. The pattern `r\"[\\d.]+\\s+sec\\s*$\"` identifies lines ending a ctest result block; the panic means the regex failed to parse. Because it is a LazyLock, the crash happens at first use during ctest output filtering, not at binary startup.","triggerScenarios":"First invocation of the ctest filter after the RESULT_TERMINATOR_RE pattern literal was edited into an invalid form — e.g. an unclosed character class `[\\d.` (unescaped `[`), a bad escape sequence, or a corrupted `$` anchor.","commonSituations":"Editing the character class to add separators (e.g. `[\\d.,]`) and accidentally deleting the `]`, regex-escaping mistakes when switching from a raw string to a regular string (backslashes being eaten), or an incomplete merge of the static block.","solutions":["Read the RESULT_TERMINATOR_RE literal at src/cmds/system/ctest_cmd.rs:35-36 and correct the regex syntax (check character class is closed with `]`)","Compile-test the pattern in isolation (regex101 Rust flavor or a unit test) before rebuilding","Restore the known-good pattern: r\"[\\d.]+\\s+sec\\s*$\"","Run `cargo test ctest` and `cargo clippy --all-targets` after the fix"],"exampleFix":"// before (unterminated character class)\nRegex::new(r\"[\\d.+\\s+sec\\s*$\").expect(\"invalid ctest result terminator regex\")\n// after\nRegex::new(r\"[\\d.]+\\s+sec\\s*$\").expect(\"invalid ctest result terminator regex\")","handlingStrategy":"validation","validationCode":"fn assert_terminator_regex_valid() {\n    assert!(regex::Regex::new(r\"[\\d.]+\\s+sec\\s*$\").is_ok());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When editing a character class, immediately re-check the closing `]`","Prefer minimal, test-covered edits to regex literals","Add a compile-time check test for all ctest regex statics","Run cargo test before pushing any change touching regex statics"],"tags":["regex","panic","character-class","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"}