Skip to content

DefaultCredentialsProvider eagerly blows up on invalid .aws/credentials #1014

Closed
@chrylis

Description

@chrylis

A colleague was having inexplicable crashes on startup when we added SDK v2 to our application. After substantial troubleshooting, we determined that it was because trying out the CLI utilities some months ago had created a file named ~/.aws/credentials:

[default]
aws_access_key_id=
aws_secret_access_key=

These values are invalid, to be sure, but the problem is that they're loaded and validated (and thus will throw an exception from ProfileCredentialsUtil#credentialsProvider) when the class DefaultCredentialsProvider is loaded. Thus, even though our application configures a StaticCredentialsProvider with everything that the SDK needs, the SDK still throws on startup.

I can see two sensible behaviors, either that the ProfileCredentialsProvider loads credentials lazily or that DefaultCredentialsProvider's default chain is initialized lazily, but unrequested credentials shouldn't be inspected for correctness and block application startup. (It also should provide a substantially better error message, such as "invalid credentials in file foo", but I'm not sure how to phrase an issue for that.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions