Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent failure when there are no NoCredentialProviders #579

Closed
josh-padnick opened this issue Mar 7, 2016 · 6 comments
Closed

Silent failure when there are no NoCredentialProviders #579

josh-padnick opened this issue Mar 7, 2016 · 6 comments
Assignees
Labels
documentation This is a problem with documentation.

Comments

@josh-padnick
Copy link

I've noticed that when I run the following code:

svc := ec2.New(session.New(), aws.NewConfig().WithRegion(region))

params := &ec2.DescribeAvailabilityZonesInput{
    DryRun: aws.Bool(false),
}

If no credentials are provided using the documented methods of specifying credentials, then there appears to be no panic or other interruption.

I've also tried the WithLogger() option to specify an aws.Logger and still don't see any log output on stdout.

Is this silent failure a known issue, or am I missing something? Also, I was thinking about calling credentials.Get() but then I see this error when there are no credentials defined:

NoCredentialProviders: no valid providers in chain. Deprecated.
    For verbose messaging see aws.Config.CredentialsChainVerboseErrors

So perhaps I don't want to use this error since it's deprecated?

Would appreciate some best-practices guidance here so users of my library receive nice error messages if they fail to specify credentials.

@josh-padnick
Copy link
Author

Ok, just saw #413, but looks like that's been rolled back in favor of #517. But when I use:

svc := ec2.New(session.New(), aws.NewConfig().WithRegion(region).WithCredentialsChainVerboseErrors(true))

params := &ec2.DescribeAvailabilityZonesInput{
    DryRun: aws.Bool(false),
}

I still don't receive any logging output?

@xibz
Copy link
Contributor

xibz commented Mar 7, 2016

Hello @josh-padnick, thank you for reaching out to us. I am curious to how you are attempting to grab the verbose errors. Are you grabbing the verbose errors by calling Get on the Credentials? We do not log these errors. This just enables chaining of errors.

@josh-padnick
Copy link
Author

I was using Credentials.Get() and catching the err. I actually don't see a Retrieve() method on Credentials?

Here's my full code:

svc := ec2.New(session.New(), aws.NewConfig().WithRegion(region))
    _, err := svc.Config.Credentials.Get()
    if err != nil {
        log.Fatalf("Failed to open EC2 session: %s\n", err.Error())
    }

This works fine, but it's non-obvious to have to do this test. It seems like ec2.New should panic or at least return an err if it can't successfully authenticate.

@xibz
Copy link
Contributor

xibz commented Mar 7, 2016

Sorry, yes, I meant Get. Updated old message to be correct. Unfortunately, we cannot have it return an error, because this would be a breaking change for people. In addition, a panic doesn't seem right here; killing someone's program for this seems a little harsh.

We can update the docs to be more explicit and add this to the backlog for the future. Thank you for the feedback and we'll do our best to make the use of the SDK more intuitive.

@xibz xibz added the documentation This is a problem with documentation. label Mar 7, 2016
@josh-padnick
Copy link
Author

Ah, got it. Yeah, docs would be a big help since I kept thinking there was something I was missing by not seeing any errors/logs/panics. Thanks for the prompt responsiveness!

@josh-padnick josh-padnick reopened this Mar 7, 2016
@xibz xibz self-assigned this Mar 7, 2016
@xibz
Copy link
Contributor

xibz commented Mar 7, 2016

I've updated the github wiki to include an example of checking if credentials have been loaded properly.
At the bottom of Specifying Profiles. Going to close this issue. If you have any feedback or requests, please let us know.

@xibz xibz closed this as completed Mar 7, 2016
skotambkar added a commit to skotambkar/aws-sdk-go that referenced this issue May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation.
Projects
None yet
Development

No branches or pull requests

2 participants