{"record":{"id":"560ea031f923272d","repo":"pola-rs/polars","slug":"cannot-use-credential-provider-when-passing-a-delt-560ea0","errorCode":null,"errorMessage":"cannot use credential_provider when passing a DeltaTable object","messagePattern":"cannot use credential_provider when passing a DeltaTable object","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/delta/functions.py","lineNumber":309,"sourceCode":"    from polars.io.cloud.credential_provider._builder import (\n        _init_credential_provider_builder,\n    )\n\n    table: DeltaTable | None = None\n\n    if importlib.util.find_spec(\"deltalake\") is not None:\n        from deltalake import DeltaTable\n\n        if isinstance(source, DeltaTable):\n            table = source\n\n    if table is None:\n        credential_provider_builder = _init_credential_provider_builder(\n            credential_provider, source, storage_options, \"scan_delta\"\n        )\n    elif credential_provider is not None and credential_provider != \"auto\":\n        msg = \"cannot use credential_provider when passing a DeltaTable object\"\n        raise ValueError(msg)\n    else:\n        credential_provider_builder = None\n\n    del credential_provider\n\n    if table is not None and (\n        table._storage_options is not None or storage_options is not None\n    ):\n        storage_options = {\n            **(table._storage_options or {}),\n            **(storage_options or {}),\n        }\n\n    dataset = DeltaDataset(\n        table_=NoPickleOption(table),\n        table_uri_=str(source) if table is None else None,\n        version=version,\n        storage_options=storage_options,","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/io/delta/functions.py#L291-L327","documentation":"Raised by scan_delta (and the related read path) when source is an existing DeltaTable object and credential_provider is also passed (anything other than the default 'auto'). A DeltaTable already carries its own authenticated handles; applying an extra credential provider on top of it is contradictory, so polars rejects it.","triggerScenarios":"pl.scan_delta(delta_table_obj, credential_provider=my_provider); code that unconditionally threads a credential provider through every call, including ones given a pre-built DeltaTable.","commonSituations":"Cloud credential helpers (GCP/ADLS/AWS factories) wired into generic wrappers; refactoring where source changed from a path to a shared DeltaTable but the credential plumbing was left in place.","solutions":["Drop the credential_provider argument when passing a DeltaTable — build the DeltaTable with its own storage_options/credentials instead","Or pass the table location string (not the object) and keep credential_provider, letting polars construct the table","In shared wrappers, only forward credential_provider when source is a str/path"],"exampleFix":"# before\npl.scan_delta(delta_table, credential_provider=credential_provider_func)\n\n# after\npl.scan_delta(delta_table)\n# or\npl.scan_delta(\"s3://bucket/table\", credential_provider=credential_provider_func)","handlingStrategy":"validation","validationCode":"from deltalake import DeltaTable\n\nif isinstance(source, DeltaTable):\n    assert credential_provider in (None, \"auto\"), \"drop credential_provider for DeltaTable input\"","typeGuard":"from deltalake import DeltaTable\n\ndef is_delta_table(source: object) -> TypeGuard[DeltaTable]:\n    return isinstance(source, DeltaTable)","tryCatchPattern":null,"preventionTips":["Build DeltaTable objects with storage_options/credentials at construction, then pass them bare to scan_delta","Only thread credential_provider through wrappers when source is a str/path","Treat 'auto' as the only acceptable default alongside DeltaTable sources"],"tags":["delta-lake","credentials","api-misuse","validation"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}