{"record":{"id":"ed6868ff0e2e3a7f","repo":"mitmproxy/mitmproxy","slug":"invalid-regular-expression-spec-subject-r-e","errorCode":null,"errorMessage":"Invalid regular expression {spec.subject!r} ({e})","messagePattern":"Invalid regular expression (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mitmproxy/addons/mapremote.py","lineNumber":24,"sourceCode":"from mitmproxy import exceptions\nfrom mitmproxy import flowfilter\nfrom mitmproxy import http\nfrom mitmproxy.utils.spec import parse_spec\n\n\nclass MapRemoteSpec(NamedTuple):\n    matches: flowfilter.TFilter\n    subject: str\n    replacement: str\n\n\ndef parse_map_remote_spec(option: str) -> MapRemoteSpec:\n    spec = MapRemoteSpec(*parse_spec(option))\n\n    try:\n        re.compile(spec.subject)\n    except re.error as e:\n        raise ValueError(f\"Invalid regular expression {spec.subject!r} ({e})\")\n\n    return spec\n\n\nclass MapRemote:\n    def __init__(self) -> None:\n        self.replacements: list[MapRemoteSpec] = []\n\n    def load(self, loader):\n        loader.add_option(\n            \"map_remote\",\n            Sequence[str],\n            [],\n            \"\"\"\n            Map remote resources to another remote URL using a pattern of the form\n            \"[/flow-filter]/url-regex/replacement\", where the separator can\n            be any character.\n            \"\"\",","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/mitmproxy/mitmproxy/blob/2ac5b089d953585c66026a53f678270e094e48e5/mitmproxy/addons/mapremote.py#L6-L42","documentation":"Error \"Invalid regular expression {spec.subject!r} ({e})\" thrown in mitmproxy/mitmproxy.","triggerScenarios":"Thrown at mitmproxy/addons/mapremote.py:24 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"}