{"record":{"id":"94fb7eabe22aacf7","repo":"sinelaw/fresh","slug":"regex-compile-error","errorCode":null,"errorMessage":"(regex compile error)","messagePattern":"\\(regex compile error\\)","errorType":"exception","errorClass":"io::Error (InvalidInput)","httpStatus":null,"severity":"warning","filePath":"crates/fresh-editor-core/src/model/filesystem.rs","lineNumber":905,"sourceCode":"    };\n    let re_pattern = if opts.whole_word {\n        format!(r\"\\b{}\\b\", re_pattern)\n    } else {\n        re_pattern\n    };\n    let re_pattern = if opts.case_sensitive {\n        re_pattern\n    } else {\n        format!(\"(?i){}\", re_pattern)\n    };\n    // Multi-line regex patterns get (?s) so `.` matches newlines.\n    let re_pattern = if !opts.fixed_string && pattern.contains('\\n') {\n        format!(\"(?s){}\", re_pattern)\n    } else {\n        re_pattern\n    };\n    regex::bytes::Regex::new(&re_pattern)\n        .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))\n}\n\n/// Maximum per-file size for unbounded project-wide search.  Files larger\n/// than this are treated as binary and skipped: searching multi-gigabyte\n/// archives, model weights, or audio files would otherwise lock up the\n/// editor for minutes (issue #1342).  Source files virtually never exceed\n/// this limit; users wanting to search huge text logs should open them\n/// directly so hybrid buffer search applies.\npub const MAX_PROJECT_SEARCH_FILE_SIZE: u64 = 10 * 1024 * 1024;\n\n/// Filename extensions that always represent binary content for project\n/// search.  Files matching this list are skipped before any I/O — no\n/// `stat`, no header read — which both avoids waste on the obvious cases\n/// and removes the dependency on heuristic content detection for formats\n/// whose first 8 KB can occasionally look text-like.\n///\n/// Kept as a sorted ASCII-lowercase list and matched case-insensitively\n/// via `eq_ignore_ascii_case` (no allocation per file).","sourceCodeStart":887,"sourceCodeEnd":923,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor-core/src/model/filesystem.rs#L887-L923","documentation":"Project search fails when the search pattern cannot be compiled as a regex (regex::bytes::Regex::new returns Err). The library wraps the regex error as InvalidInput; this is a user-supplied pattern problem, not an internal bug. Multi-line patterns additionally get a (?s) prefix before compiling.","triggerScenarios":"Running search with fixed_string disabled and a pattern containing invalid regex syntax (unbalanced parenthesis, bad quantifier like `*foo`, invalid escape `\\q`), including multi-line patterns routed through the (?s) wrapper.","commonSituations":"Users typing globs/wildcard-style patterns expecting shell semantics; patterns copied with unescaped special characters; searching for literal text containing regex metacharacters without fixed-string mode.","solutions":["Fix the regex syntax (balance groups, escape metacharacters with backslash).","Enable fixed_string option to search literally without regex interpretation.","Test the pattern in a regex validator (rust regex crate flavor) before searching."],"exampleFix":"// before\nSearchOptions { pattern: \"foo(bar\".into(), fixed_string: false, .. }\n// after\nSearchOptions { pattern: \"foo\\\\(bar\".into(), fixed_string: false, .. }\n// or\nSearchOptions { pattern: \"foo(bar\".into(), fixed_string: true, .. }","handlingStrategy":"validation","validationCode":"if !opts.fixed_string {\n    if let Err(e) = regex::bytes::Regex::new(&opts.pattern) {\n        eprintln!(\"invalid search pattern: {e}\");\n        return;\n    }\n}","typeGuard":null,"tryCatchPattern":"match run_search(pattern, opts) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n    // surface the regex error to the user and offer fixed-string mode\n    prompt_fixed_string_fallback(pattern)?;\n    }\n    other => other?,\n}","preventionTips":["Precompile/validate patterns in the UI before running search","Escape metacharacters when the user means a literal search","Offer a fixed-string toggle as a fallback"],"tags":["regex","search","user-input"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}