{"record":{"id":"ea63792e42bba85a","repo":"mitmproxy/mitmproxy","slug":"invalid-regular-expression-regex-r-e","errorCode":null,"errorMessage":"Invalid regular expression {regex!r} ({e})","messagePattern":"Invalid regular expression (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mitmproxy/addons/maplocal.py","lineNumber":31,"sourceCode":"from mitmproxy import flowfilter\nfrom mitmproxy import http\nfrom mitmproxy import version\nfrom mitmproxy.utils.spec import parse_spec\n\n\nclass MapLocalSpec(NamedTuple):\n    matches: flowfilter.TFilter\n    regex: str\n    local_path: Path\n\n\ndef parse_map_local_spec(option: str) -> MapLocalSpec:\n    filter, regex, replacement = parse_spec(option)\n\n    try:\n        re.compile(regex)\n    except re.error as e:\n        raise ValueError(f\"Invalid regular expression {regex!r} ({e})\")\n\n    try:\n        path = Path(replacement).expanduser().resolve(strict=True)\n    except FileNotFoundError as e:\n        raise ValueError(f\"Invalid file path: {replacement} ({e})\")\n\n    return MapLocalSpec(filter, regex, path)\n\n\ndef _safe_path_join(root: Path, untrusted: str) -> Path:\n    \"\"\"Join a Path element with an untrusted str.\n\n    This is a convenience wrapper for werkzeug's safe_join,\n    raising a ValueError if the path is malformed.\"\"\"\n    untrusted_parts = Path(untrusted).parts\n    joined = safe_join(root.as_posix(), *untrusted_parts)\n    if joined is None:\n        raise ValueError(\"Untrusted paths.\")","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/mitmproxy/mitmproxy/blob/2ac5b089d953585c66026a53f678270e094e48e5/mitmproxy/addons/maplocal.py#L13-L49","documentation":"Error \"Invalid regular expression {regex!r} ({e})\" thrown in mitmproxy/mitmproxy.","triggerScenarios":"Thrown at mitmproxy/addons/maplocal.py:31 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2ac5b089d953585c66026a53f678270e094e48e5","analyzedAt":"2026-08-26T07:49:02.629Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}