{"record":{"id":"b33105d6ce23dbaa","repo":"zed-industries/zed","slug":"failed-to-create-regex","errorCode":null,"errorMessage":"Failed to create REGEX","messagePattern":"Failed to create REGEX","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/hover_links.rs","lineNumber":910,"sourceCode":"                                row: parsed.row,\n                                column: parsed.column,\n                            },\n                        ));\n                    }\n                }\n            }\n        }\n    }\n    None\n}\n\n// Generates candidate file paths by stripping common punctuation wrappers.\n// Handles markdown patterns like [title](path), `path`, (path), as well as\n// partial wrappers where punctuation only appears on one side (e.g. path) or path`).\n// Returns candidates ordered from most-specific (most trimmed) to least-specific (raw).\nfn link_pattern_file_candidates(candidate: &str) -> Vec<(String, Range<usize>)> {\n    static MD_LINK_REGEX: LazyLock<Regex> =\n        LazyLock::new(|| Regex::new(r\"]\\(([^)]*)\\)\").expect(\"Failed to create REGEX\"));\n\n    // Punctuation that commonly wraps file paths in prose/markdown\n    const LEADING_PUNCTUATION: &[char] = &['`', '(', '[', '{', '<', '\"', '\\''];\n    const TRAILING_PUNCTUATION: &[char] = &[\n        '`', ')', ']', '}', '>', '\"', '\\'', '.', ',', ':', ';', '!', '?',\n    ];\n\n    let candidate_len = candidate.len();\n    let mut candidates = Vec::new();\n\n    // Trim leading and trailing punctuation iteratively\n    let mut start = 0;\n    let mut end = candidate_len;\n\n    // Trim leading punctuation\n    for ch in candidate.chars() {\n        if LEADING_PUNCTUATION.contains(&ch) {\n            start += ch.len_utf8();","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/editor/src/hover_links.rs#L892-L928","documentation":"A static-initialization guard: link_pattern_file_candidates compiles a fixed Regex via LazyLock and expects it to succeed. Regex::new on a hardcoded literal only fails if the pattern itself is malformed, so this panic indicates a programming error in the committed pattern string, not any user input or runtime condition — the regex is compiled once per process from a constant.","triggerScenarios":"Thrown at crates/editor/src/hover_links.rs:910 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a unit test that constructs the regex (exercises the LazyLock) so a bad pattern fails CI instead of at runtime","Prefer a checked compile with a documented invariant comment, keeping expect only where a test guarantees it","Use a regex crate macro (e.g. regex!) if available to validate at compile time"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}