{"record":{"id":"405f613f62ccb60e","repo":"Hmbown/CodeWhale","slug":"static-notification-redaction-pattern-must-compile","errorCode":null,"errorMessage":"static notification redaction pattern must compile","messagePattern":"static notification redaction pattern must compile","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/notification_payload.rs","lineNumber":305,"sourceCode":"            let redacted = redact_credentials(&redacted);\n            let redacted = redact_absolute_paths(&redacted);\n            // Collapse whitespace runs so a bounded field cannot be\n            // padded out with invisible filler.\n            redacted.split_whitespace().collect::<Vec<_>>().join(\" \")\n        })\n        .filter(|line| !line.is_empty())\n        .collect::<Vec<_>>()\n        .join(\" \")\n}\n\nfn regex_cache<const N: usize>(\n    cell: &'static OnceLock<Vec<Regex>>,\n    patterns: [&str; N],\n) -> &'static [Regex] {\n    cell.get_or_init(|| {\n        patterns\n            .iter()\n            .map(|p| Regex::new(p).expect(\"static notification redaction pattern must compile\"))\n            .collect()\n    })\n}\n\n/// Remove complete ANSI escape sequences (CSI, OSC, and single-character\n/// escapes) so neither the sequence nor its parameter tail survives into a\n/// notification field.\nfn strip_escape_sequences(text: &str) -> String {\n    static PATTERNS: OnceLock<Vec<Regex>> = OnceLock::new();\n    let res = regex_cache(\n        &PATTERNS,\n        [\n            // OSC: ESC ] … terminated by BEL or ST.\n            r\"\\x1b\\][^\\x07\\x1b]*(?:\\x07|\\x1b\\\\)?\",\n            // CSI: ESC [ params intermediates final.\n            r\"\\x1b\\[[0-9;?<>=]*[ -/]*[@-~]?\",\n            // Any remaining two-character escape.\n            r\"\\x1b.\",","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tui/notification_payload.rs#L287-L323","documentation":"regex_cache compiles a fixed set of static notification redaction patterns (credential, path, and structured-field regexes) into a OnceLock. The expect fires only if one of the hardcoded literal patterns is invalid — a programmer error surfaced on the first redaction call — never because of the notification content being redacted.","triggerScenarios":"Thrown at crates/tui/src/tui/notification_payload.rs:305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Cover every redaction pattern list with a unit test so invalid literals fail in CI","Keep patterns as string literals; validate new patterns with a quick Regex::new before committing","Keep the generic const N signature so pattern sets stay compile-time sized"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}