{"record":{"id":"2606f9dcb831503a","repo":"unclecode/crawl4ai","slug":"invalid-regex-for-lbl-e","errorCode":null,"errorMessage":"Invalid regex for '{lbl}': {e}","messagePattern":"Invalid regex for '(.+?)': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/extraction_strategy.py","lineNumber":2825,"sourceCode":"            extra_args=kwargs,\n        )\n\n        # ── clean & load JSON (fix common escape mistakes *before* json.loads)\n        raw = resp.choices[0].message.content\n        raw = raw.replace(\"\\x08\", \"\\\\b\")                     # stray back-space → \\b\n        raw = re.sub(r'(?<!\\\\)\\\\(?![\\\\u\"])', r\"\\\\\\\\\", raw)   # lone \\ → \\\\\n\n        try:\n            pattern_dict = json.loads(raw)\n        except Exception as exc:\n            raise ValueError(f\"LLM did not return valid JSON: {raw}\") from exc\n\n        # quick sanity-compile\n        for lbl, pat in pattern_dict.items():\n            try:\n                re.compile(pat)\n            except re.error as e:\n                raise ValueError(f\"Invalid regex for '{lbl}': {e}\") from None\n\n        return pattern_dict\n","sourceCodeStart":2807,"sourceCodeEnd":2828,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/extraction_strategy.py#L2807-L2828","documentation":"Error \"Invalid regex for '{lbl}': {e}\" thrown in unclecode/crawl4ai.","triggerScenarios":"Thrown at crawl4ai/extraction_strategy.py:2825 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the regular expression for the given label; test it with re.compile before passing it to the strategy.","Escape special characters that are meant to be literal in the pattern."],"exampleFix":"re.compile(pattern)  # validate before use in RegexExtractionStrategy","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}