{"record":{"id":"1dc76350b11c84f4","repo":"rtk-ai/rtk","slug":"valid-regex","errorCode":null,"errorMessage":"valid regex","messagePattern":"valid regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/dotnet/binlog.rs","lineNumber":74,"sourceCode":"    Regex::new(\n        r\"(?m)^\\s*(?P<file>[^\\r\\n:(]+)\\((?P<line>\\d+),(?P<column>\\d+)\\):\\s*(?P<kind>error|warning)\\s*(?:(?P<code>[A-Za-z]+\\d+)\\s*:\\s*)?(?P<msg>.*)$\"\n    )\n    .expect(\"valid regex\")\n});\nstatic BUILD_SUMMARY_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"(?mi)^\\s*(?P<count>\\d+)\\s+(?P<kind>warning|error)\\(s\\)\").expect(\"valid regex\")\n});\nstatic ERROR_COUNT_RE: LazyLock<Regex> =\n    LazyLock::new(|| Regex::new(r\"(?i)\\b(?P<count>\\d+)\\s+error\\(s\\)\").expect(\"valid regex\"));\nstatic WARNING_COUNT_RE: LazyLock<Regex> =\n    LazyLock::new(|| Regex::new(r\"(?i)\\b(?P<count>\\d+)\\s+warning\\(s\\)\").expect(\"valid regex\"));\nstatic FALLBACK_ERROR_LINE_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"(?mi)^.+\\(\\d+,\\d+\\):\\s*error(?:\\s+[A-Za-z]{2,}\\d{3,})?(?:\\s*:.*)?$\")\n        .expect(\"valid regex\")\n});\nstatic FALLBACK_WARNING_LINE_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"(?mi)^.+\\(\\d+,\\d+\\):\\s*warning(?:\\s+[A-Za-z]{2,}\\d{3,})?(?:\\s*:.*)?$\")\n        .expect(\"valid regex\")\n});\nstatic DURATION_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"(?m)^\\s*Time Elapsed\\s+(?P<duration>[^\\r\\n]+)$\").expect(\"valid regex\")\n});\nstatic TEST_RESULT_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(\n        r\"(?m)(?:Passed!|Failed!)\\s*-\\s*Failed:\\s*(?P<failed>\\d+),\\s*Passed:\\s*(?P<passed>\\d+),\\s*Skipped:\\s*(?P<skipped>\\d+),\\s*Total:\\s*(?P<total>\\d+),\\s*Duration:\\s*(?P<duration>[^\\r\\n-]+)\"\n    )\n    .expect(\"valid regex\")\n});\nstatic TEST_SUMMARY_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(\n        r\"(?mi)^\\s*Test summary:\\s*total:\\s*(?P<total>\\d+),\\s*failed:\\s*(?P<failed>\\d+),\\s*(?:succeeded|passed):\\s*(?P<passed>\\d+),\\s*skipped:\\s*(?P<skipped>\\d+),\\s*duration:\\s*(?P<duration>[^\\r\\n]+)$\"\n    )\n    .expect(\"valid regex\")\n});\nstatic FAILED_TEST_HEAD_RE: LazyLock<Regex> = LazyLock::new(|| {\n    Regex::new(r\"(?m)^\\s*Failed\\s+(?P<name>[^\\r\\n\\[]+)\\s+\\[[^\\]\\r\\n]+\\]\\s*$\").expect(\"valid regex\")","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/dotnet/binlog.rs#L56-L92","documentation":"This is a LazyLock static initialization for the binlog fallback error-line regex. `.expect(\"valid regex\")` panics (not a recoverable error) if the hard-coded pattern fails to compile — which for the shipped pattern only happens in a corrupted build where the literal was modified.","triggerScenarios":"First use of the dotnet binlog filter triggers static init; the panic occurs only if the embedded regex literal is invalid, which cannot happen with the released pattern. Effectively an internal-invariant assertion at module init.","commonSituations":"Custom forks/patches editing the regex and introducing invalid syntax (unbalanced parens, bad escapes); regressions from automated refactors touching the string literal.","solutions":["Verify the regex literal in src/cmds/dotnet/binlog.rs compiles (test it in regex101 with the regex crate syntax).","Revert any local modifications to FALLBACK_ERROR_LINE_RE.","Rebuild from a clean checkout: cargo clean && cargo build."],"exampleFix":"// before\nRegex::new(r\"(?mi)^.+\\(\\d+,\\d+\\):\\s*error(?:\\s+[A-Za-z]{2,}\\d{3,})?(?:\\s*:.*)?$\").expect(\"valid regex\") // edited literal broke it\n// after\nrestore the original literal, or validate: Regex::new(PATTERN)? in a test","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// statics cannot be caught; guard at build time\n#[test]\nfn fallback_error_line_re_compiles() {\n    assert!(Regex::new(r\"(?mi)^.+\\(\\d+,\\d+\\):\\s*error(?:\\s+[A-Za-z]{2,}\\d{3,})?(?:\\s*:.*)?$\").is_ok());\n}","preventionTips":["Never edit hard-coded regex literals without a compile test","Keep statics unmodified from upstream; extend via new patterns in tests first","Run cargo test before committing changes to binlog.rs"],"tags":["regex","panic","dotnet"],"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"}