{"record":{"id":"b5aa70beeeba9589","repo":"pola-rs/polars","slug":"unsupported-cannot-combine-token-with-unhandled","errorCode":null,"errorMessage":"unsupported: cannot combine token with {unhandled_key} in storage_options","messagePattern":"unsupported: cannot combine token with (.+?) in storage_options","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/cloud/credential_provider/_builder.py","lineNumber":526,"sourceCode":"                    k = k.lower()\n\n                    # https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html\n                    if k in {\"token\", \"bearer_token\"}:\n                        token = v\n                    elif k in AUTOINIT_IGNORED_KEYS:\n                        continue\n                    else:\n                        # We assume some sort of access key was given, so we\n                        # just dispatch to the rust side.\n                        unhandled_key = k\n\n            if unhandled_key is not None:\n                if token is not None:\n                    msg = (\n                        \"unsupported: cannot combine token with \"\n                        f\"{unhandled_key} in storage_options\"\n                    )\n                    raise ValueError(msg)\n\n                return None\n\n            if token is not None:\n                return CredentialProviderBuilder(\n                    InitializedCredentialProvider(UserProvidedGCPToken(token))\n                )\n\n            if (default := get_default_credential_provider()) is not None:\n                return default\n\n            return CredentialProviderBuilder(AutoInit(CredentialProviderGCP))\n\n        return None\n\n    credential_provider_init = f()\n\n    if verbose():","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/cloud/credential_provider/_builder.py#L508-L544","documentation":"The auto credential-provider builder scans storage_options for a token; if an unrecognized key (e.g. an access key) is combined with an explicit token it raises, because mixing token-based auth with key-based options in one provider is ambiguous.","triggerScenarios":"Passing storage_options containing {'token': '<gcp-token>'} together with other credential keys (e.g. google_service_account, service-account key JSON, aws keys) when a credential provider is being built.","commonSituations":"Merging storage_options from multiple sources where one adds a token and another adds service-account credentials; switching from service-account auth to token auth without cleaning old keys.","solutions":["Remove the extra credential keys, keeping only the token.","Or remove the token and use the service-account/other credentials alone.","Split storage_options per auth strategy instead of merging dicts."],"exampleFix":"// before\n opts = {\"token\": tok, \"google_service_account\": sa_path}\n// after\n opts = {\"token\": tok}  # or only google_service_account","handlingStrategy":"validation","validationCode":"if 'token' in opts and len(opts) > 1:\n    raise ValueError('token cannot be combined with other credential keys in storage_options')","typeGuard":"def token_only(opts: dict) -> dict:\n    if 'token' in opts and set(opts) != {'token'}:\n        return {'token': opts['token']}\n    return opts","tryCatchPattern":"try:\n    lf = pl.scan_parquet(url, storage_options=opts)\nexcept ValueError as e:\n    if 'cannot combine token' in str(e):\n        opts = {'token': opts['token']}\n        lf = pl.scan_parquet(url, storage_options=opts)\n    else:\n        raise","preventionTips":["Pick one GCP auth mechanism (token OR service account) and filter storage_options accordingly.","Validate merged storage_options before use with a whitelist of allowed key sets.","Add a unit test that builds storage_options and asserts mutual exclusivity."],"tags":["python","gcp","credentials","storage-options"],"backgroundTag":"mutually-exclusive-options","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"}