{"record":{"id":"6d4db93f18ab2dfe","repo":"pola-rs/polars","slug":"unsupported-cannot-combine-aws-profile-with-unha","errorCode":null,"errorMessage":"unsupported: cannot combine aws_profile with {unhandled_key} in storage_options","messagePattern":"unsupported: cannot combine aws_profile with (.+?) in storage_options","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/cloud/credential_provider/_builder.py","lineNumber":484,"sourceCode":"                        \"aws_endpoint\",\n                        \"aws_endpoint_url\",\n                        \"endpoint\",\n                        \"endpoint_url\",\n                    }:\n                        has_endpoint_url = True\n                    elif k in AUTOINIT_IGNORED_KEYS:\n                        continue\n                    else:\n                        # We assume this is some sort of access key\n                        unhandled_key = k\n\n            if unhandled_key is not None:\n                if profile is not None:\n                    msg = (\n                        \"unsupported: cannot combine aws_profile with \"\n                        f\"{unhandled_key} in storage_options\"\n                    )\n                    raise ValueError(msg)\n\n            if (\n                unhandled_key is None\n                and (default := get_default_credential_provider()) is not None\n            ):\n                return default\n\n            return CredentialProviderBuilder(\n                AutoInit(\n                    CredentialProviderAWS,\n                    profile_name=profile,\n                    region_name=region or default_region,\n                    _auto_init_unhandled_key=unhandled_key,\n                    _storage_options_has_endpoint_url=has_endpoint_url,\n                )\n            )\n\n        elif _is_gcp_cloud(scheme):","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/cloud/credential_provider/_builder.py#L466-L502","documentation":"The credential provider builder rejects combining the aws_profile selection mechanism with any other unhandled storage_options key, since profile-based credential resolution cannot be reconciled with explicit credentials in the same options dict.","triggerScenarios":"Passing storage_options that include both aws_profile (e.g. {'aws_profile': 'prod'}) and another credential key such as aws_access_key_id/aws_session_token, or a cloud provider token, when building an AWS credential provider.","commonSituations":"Merging two configs — a shared base dict containing aws_profile plus a per-environment dict with explicit keys; leftover keys after switching auth strategies; templated storage_options that concatenate both styles.","solutions":["Remove aws_profile from storage_options when supplying explicit credentials.","Or remove the explicit credential keys and rely solely on the AWS profile.","Move profile selection to the aws CLI/config files (~/.aws/config) instead of storage_options."],"exampleFix":"// before\n opts = {\"aws_profile\": \"prod\", \"aws_access_key_id\": k, \"aws_secret_access_key\": s}\n// after\n opts = {\"aws_access_key_id\": k, \"aws_secret_access_key\": s}  # drop aws_profile","handlingStrategy":"validation","validationCode":"if 'aws_profile' in opts and len(opts) > 1:\n    raise ValueError('aws_profile cannot be combined with other credential keys in storage_options')","typeGuard":"def opts_are_consistent(opts: dict) -> bool:\n    return not ('aws_profile' in opts and any(k != 'aws_profile' for k in opts))","tryCatchPattern":"try:\n    lf = pl.scan_parquet(url, storage_options=opts)\nexcept ValueError as e:\n    if 'cannot combine aws_profile' in str(e):\n        opts = {k: v for k, v in opts.items() if k == 'aws_profile'}\n        lf = pl.scan_parquet(url, storage_options=opts)\n    else:\n        raise","preventionTips":["Keep a single auth strategy per storage_options dict; never merge profile-based and key-based configs.","Centralize storage_options construction in one helper that validates exclusivity.","When migrating auth strategies, explicitly delete obsolete keys."],"tags":["python","aws","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"}