{"record":{"id":"808ced0343a5dfb5","repo":"rtk-ai/rtk","slug":"invalid-ctest-result-prefix-regex","errorCode":null,"errorMessage":"invalid ctest result prefix regex","messagePattern":"invalid ctest result prefix regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/system/ctest_cmd.rs","lineNumber":31,"sourceCode":"\nconst MAX_SLOWEST: usize = 3;\nconst MAX_FAILURE_LINES: usize = CAP_WARNINGS;\nconst 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 {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/system/ctest_cmd.rs#L13-L49","documentation":"This panic message comes from an .expect() on Regex::new for the RESULT_RE static in src/cmds/system/ctest_cmd.rs, which parses ctest 'Test #N: name ... Passed/Failed <time> sec' result lines. rtk compiles its filter regexes once in LazyLock statics; if the pattern were syntactically invalid the program panics at first access instead of returning an error. This is an internal invariant guard — the shipped pattern is valid, so end users should never see it.","triggerScenarios":"First access of RESULT_RE during an `rtk ctest` run, if the compiled binary was built from a source edit that broke the regex syntax (e.g. an unbalanced parenthesis or a bad escape like \\s misspelled in the raw string).","commonSituations":"Developers modifying the ctest filter's regex and shipping a typo; tooling or macros mangling the raw string literal; backporting the pattern to an older regex crate whose syntax differs.","solutions":["Check the regex literal near the expect in src/cmds/system/ctest_cmd.rs for syntax errors (balanced groups, valid escapes) and fix it","Verify the regex crate version compiles the pattern: `cargo test ctest` or a quick Regex::new in a test","If you only want output, bypass the filter with `rtk proxy ctest ...` to run ctest unfiltered","Rebuild from a clean tree: `cargo build` and confirm the panic disappears"],"exampleFix":"// before\nRegex::new(r\"(?s)^\\s*(?:\\d+/(\\d+)\\s+)?Test\\s+#(\\d+):\\s+(.+?)\\s+\\.{2,}\\s*(?:\\*{3})?\\s*(.+?)\\s+([\\d.]+)\\s+sec\\s*$\").expect(\"invalid ctest result regex\")\n// after (fix syntax, e.g. missing group close)\nRegex::new(r\"(?s)^\\s*(?:\\d+/(\\d+)\\s+)?Test\\s+#(\\d+):\\s+(.+?)\\s+\\.{2,}\\s*(?:\\*{3})?\\s*(.+?)\\s+([\\d.]+)\\s+sec\\s*$)\").expect(\"invalid ctest result regex\")","handlingStrategy":"validation","validationCode":"// Rust, at build/dev time\nassert!(regex::Regex::new(r\"(?s)^\\s*(?:\\d+/(\\d+)\\s+)?Test\\s+#(\\d+):\\s+(.+?)\\s+\\.{2,}\\s*(?:\\*{3})?\\s*(.+?)\\s+([\\d.]+)\\s+sec\\s*$\").is_ok(), \"RESULT_RE must compile\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep every ctest regex in a #[test] that constructs each static pattern","Run cargo test before shipping regex edits","Prefer returning Result over expect when introducing new dynamic patterns","Bypass filters with `rtk proxy ctest ...` if output is blocked"],"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"}