{"record":{"id":"f6386de5e9e8f159","repo":"pola-rs/polars","slug":"unknown-type-for-catalog-parameter-type-catalog","errorCode":null,"errorMessage":"unknown type for `catalog` parameter: {type(catalog)}","messagePattern":"unknown type for `catalog` parameter: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/iceberg/_dataset.py","lineNumber":166,"sourceCode":"    @staticmethod\n    def _from_api_parameter_or_environment_default(\n        catalog: pyiceberg.catalog.Catalog | IcebergCatalogConfig | None,\n        *,\n        fn_name: Literal[\"scan_iceberg\", \"sink_iceberg\"],\n    ) -> IcebergCatalogConfig:\n        import pyiceberg.catalog\n        from pyiceberg.catalog.noop import NoopCatalog\n\n        import polars._utils.logging\n        from polars._utils.logging import eprint\n\n        if isinstance(catalog, IcebergCatalogConfig):\n            catalog_config = catalog\n        elif isinstance(catalog, pyiceberg.catalog.Catalog):\n            catalog_config = IcebergCatalogConfig.from_catalog(catalog)\n        elif catalog is not None:\n            msg = f\"unknown type for `catalog` parameter: {type(catalog)}\"\n            raise TypeError(msg)\n        else:\n            if polars._utils.logging.verbose():\n                eprint(f\"{fn_name}(): calling pyiceberg.catalog.load_catalog()\")\n\n            try:\n                default_catalog = pyiceberg.catalog.load_catalog()\n\n            except Exception as error:\n                static_metadata_hint = (\n                    (\n                        \" \"\n                        \"If you intended to pass a static metadata path, \"\n                        \"ensure it is an absolute path.\"\n                    )\n                    if fn_name == \"scan_iceberg\"\n                    else \"\"\n                )\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/iceberg/_dataset.py#L148-L184","documentation":"The internal resolver for the `catalog` parameter of scan_iceberg/read_iceberg accepts an IcebergCatalogConfig, a pyiceberg.catalog.Catalog, or None; any other type falls through to this TypeError listing the offending type.","triggerScenarios":"pl.scan_iceberg(..., catalog='my_catalog_name') or catalog=some_dict — passing a string/dict/other object instead of a Catalog or IcebergCatalogConfig.","commonSituations":"Passing a catalog name string (as used in other frameworks like Spark/Trino) assuming polars resolves it by name.","solutions":["Pass a pyiceberg.catalog.Catalog instance, e.g. pyiceberg.catalog.load_catalog('name')","Pass None to use the default catalog resolved from the environment/IcebergCatalogConfig","Wrap config in pyiceberg's catalog load (load_catalog(name, **properties)) before passing"],"exampleFix":"// before\npl.scan_iceberg('db.tbl', catalog='glue_catalog')\n// after\nimport pyiceberg.catalog\ncat = pyiceberg.catalog.load_catalog('glue_catalog')\npl.scan_iceberg('db.tbl', catalog=cat)","handlingStrategy":"type-guard","validationCode":"import pyiceberg.catalog\nfrom pyiceberg.table import Table\ndef is_valid_catalog(c):\n    return c is None or isinstance(c, (pyiceberg.catalog.Catalog,))","typeGuard":"def is_catalog(obj) -> bool:\n    import pyiceberg.catalog\n    return isinstance(obj, pyiceberg.catalog.Catalog)","tryCatchPattern":"try:\n    lf = pl.scan_iceberg(name, catalog=catalog)\nexcept TypeError as e:\n    if 'unknown type for `catalog`' in str(e):\n        catalog = pyiceberg.catalog.load_catalog()\n        lf = pl.scan_iceberg(name, catalog=catalog)","preventionTips":["Only pass a pyiceberg Catalog object (or None) as catalog","Resolve catalog names with pyiceberg.catalog.load_catalog(name) first","Alternatively pass a pyiceberg Table object directly"],"tags":["python","polars","iceberg","type-mismatch","pyiceberg"],"backgroundTag":"type-mismatch","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}