{"record":{"id":"436a5a6ee8e0d498","repo":"Hmbown/CodeWhale","slug":"anchor-regex","errorCode":null,"errorMessage":"anchor regex","messagePattern":"anchor regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/web_run.rs","lineNumber":1347,"sourceCode":"        total_pages: pages.len(),\n        content,\n    })\n}\n\n// === HTML Parsing ===\n\nstatic ANCHOR_RE: OnceLock<Regex> = OnceLock::new();\nstatic TAG_RE: OnceLock<Regex> = OnceLock::new();\nstatic BLOCK_RE: OnceLock<Regex> = OnceLock::new();\nstatic SCRIPT_RE: OnceLock<Regex> = OnceLock::new();\nstatic STYLE_RE: OnceLock<Regex> = OnceLock::new();\nstatic TITLE_RE: OnceLock<Regex> = OnceLock::new();\nstatic MARKDOWN_LINK_RE: OnceLock<Regex> = OnceLock::new();\n\nfn get_anchor_re() -> &'static Regex {\n    ANCHOR_RE.get_or_init(|| {\n        Regex::new(r#\"(?is)<a\\s+[^>]*href\\s*=\\s*['\\\"]([^'\\\"]+)['\\\"][^>]*>(.*?)</a>\"#)\n            .expect(\"anchor regex\")\n    })\n}\n\nfn get_tag_re() -> &'static Regex {\n    TAG_RE.get_or_init(|| Regex::new(r\"<[^>]+>\").expect(\"tag regex\"))\n}\n\nfn get_block_re() -> &'static Regex {\n    BLOCK_RE.get_or_init(|| {\n        Regex::new(r\"(?is)</?(p|div|li|ul|ol|br|h[1-6]|tr|td|th|table|section|article)[^>]*>\")\n            .expect(\"block regex\")\n    })\n}\n\nfn get_script_re() -> &'static Regex {\n    SCRIPT_RE.get_or_init(|| Regex::new(r\"(?is)<script[^>]*>.*?</script>\").unwrap())\n}\n","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/tools/web_run.rs#L1329-L1365","documentation":"This expect guards the one-time compilation of the ANCHOR_RE static pattern (<a href=...> extraction) inside OnceLock::get_or_init. It fires only if the hardcoded literal regex is invalid — a programmer error caught at first use, not a runtime-input failure. A panic here means the HTML parsing module shipped a broken pattern.","triggerScenarios":"Thrown at crates/tui/src/tools/web_run.rs:1347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the pattern in a test (Regex::new in a #[test]) so CI catches a bad literal before runtime","Never build ANCHOR_RE from dynamic input; keep it a compile-time literal","If a pattern ever needs to change, run cargo test -p codewhale-tui to exercise get_anchor_re"],"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"}