{"record":{"id":"3cc5f3da78bc1689","repo":"pola-rs/polars","slug":"unsupported-table-format-table-repr-r","errorCode":null,"errorMessage":"unsupported table format: {table_repr!r}","messagePattern":"unsupported table format: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/convert/general.py","lineNumber":764,"sourceCode":"def _build_table_patterns(table_repr: TableRepr) -> _TablePatterns:\n    if table_repr is TableRepr.UTF8:\n        return _TablePatterns(\n            cell_edge=re.compile(r\"^[\\W+]*│\"),\n            cell_split=re.compile(r\"[│┆]\"),\n            header_div=re.compile(r\"^[╞═╪╡\\s]+$\"),\n            row_div=re.compile(r\"^[├╌┼┤─]+$\"),\n            rstrip_chars=\"│ \",\n        )\n    elif table_repr is TableRepr.ASCII:\n        return _TablePatterns(\n            cell_edge=re.compile(r\"^[\\W+]*[|]\"),\n            cell_split=re.compile(r\"[|]\"),\n            header_div=re.compile(r\"^[+=\\-\\s]+$\"),\n            row_div=re.compile(r\"^[|+\\-]+$\"),\n            rstrip_chars=\"| \",\n        )\n    msg = f\"unsupported table format: {table_repr!r}\"\n    raise ValueError(msg)\n\n\nclass TableRepr(Enum):  # noqa: D101\n    UTF8 = auto()\n    ASCII = auto()\n\n    @property\n    def patterns(self) -> _TablePatterns:  # noqa: D102\n        try:\n            return _TABLE_PATTERNS_CACHE[self]\n        except KeyError:\n            rx = _build_table_patterns(self)\n            _TABLE_PATTERNS_CACHE[self] = rx\n            return rx\n\n\ndef _extract_table(data: str) -> tuple[str, TableRepr] | None:\n    \"\"\"Extract a DataFrame table string and infer its format from the input.\"\"\"","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/convert/general.py#L746-L782","documentation":"Raised by polars' internal _build_table_patterns when asked for the parsing regexes of a TableRepr value that is neither TableRepr.UTF8 nor TableRepr.ASCII. TableRepr.patterns looks up cached patterns and builds them on miss, so any new or synthetic enum member without a matching branch lands here. In practice this is defensive internal validation backing from_repr table parsing, not a user-input error.","triggerScenarios":"Monkeypatching or subclassing TableRepr and adding a new member (e.g. HTML) then calling .patterns on it; passing a raw integer/invalid value to internal table-parsing functions that expect a TableRepr enum; contributing a new repr format to polars without adding a branch in _build_table_patterns.","commonSituations":"Almost exclusively a polars-internal or contributor error; end users only see it if they tamper with the TableRepr enum or call the private _build_table_patterns / _TablePatterns machinery directly.","solutions":["Use only TableRepr.UTF8 or TableRepr.ASCII; do not fabricate enum members","If extending polars with a new repr format, add a matching branch in _build_table_patterns and a cache entry","If you called a private helper directly, go through the public API (pl.from_repr) instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from polars.convert.general import TableRepr\n\nassert isinstance(table_repr, TableRepr) and table_repr in (TableRepr.UTF8, TableRepr.ASCII), table_repr","typeGuard":"from polars.convert.general import TableRepr\n\ndef is_supported_repr(r: object) -> bool:\n    return isinstance(r, TableRepr) and r in (TableRepr.UTF8, TableRepr.ASCII)","tryCatchPattern":null,"preventionTips":["Do not call private _build_table_patterns/_TablePatterns APIs; use TableRepr.patterns or pl.from_repr","Never extend or monkeypatch the TableRepr enum","When contributing a new repr format, add its branch and tests in the same change"],"tags":["internal","enum","from-repr","table-parsing"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}