Hmbown/CodeWhale · error
static notification redaction pattern must compile
Error message
static notification redaction pattern must compile
What it means
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.
Source
Thrown at crates/tui/src/tui/notification_payload.rs:305
let redacted = redact_credentials(&redacted);
let redacted = redact_absolute_paths(&redacted);
// Collapse whitespace runs so a bounded field cannot be
// padded out with invisible filler.
redacted.split_whitespace().collect::<Vec<_>>().join(" ")
})
.filter(|line| !line.is_empty())
.collect::<Vec<_>>()
.join(" ")
}
fn regex_cache<const N: usize>(
cell: &'static OnceLock<Vec<Regex>>,
patterns: [&str; N],
) -> &'static [Regex] {
cell.get_or_init(|| {
patterns
.iter()
.map(|p| Regex::new(p).expect("static notification redaction pattern must compile"))
.collect()
})
}
/// Remove complete ANSI escape sequences (CSI, OSC, and single-character
/// escapes) so neither the sequence nor its parameter tail survives into a
/// notification field.
fn strip_escape_sequences(text: &str) -> String {
static PATTERNS: OnceLock<Vec<Regex>> = OnceLock::new();
let res = regex_cache(
&PATTERNS,
[
// OSC: ESC ] … terminated by BEL or ST.
r"\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?",
// CSI: ESC [ params intermediates final.
r"\x1b\[[0-9;?<>=]*[ -/]*[@-~]?",
// Any remaining two-character escape.
r"\x1b.",View on GitHub (pinned to 0c42157ee5)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/tui/notification_payload.rs:305 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/405f613f62ccb60e.
Report an issue: GitHub.