Friendlier handling of incomplete local AWS credentials#159
Open
blsmth wants to merge 1 commit into
Open
Conversation
OAuth-authenticated commands no longer read the local ~/.aws shared config files at all (they inject their own credentials), so a partial [default] profile no longer breaks every non-auth command. The --aws-credentials paths, which do read local config by design, now wrap the SDK's opaque 'partial credentials' error with a hint pointing at the real cause. Closes #155
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #155.
Problem
With a partially-configured
defaultprofile (or strayAWS_*env vars), every command exceptapppack authfailed with the raw SDK error:authworked because it's a pure OAuth flow; everything else callsLoadDefaultConfig, which eagerly loads and validates the local~/.awsfiles before doing any real work.Key finding
I reproduced this and confirmed the SDK trips on a partial
[default]profile even when static credentials are supplied viaWithCredentialsProvider— so just wrapping the error (the original proposal) wouldn't make OAuth-authenticated commands work; it would only reword the failure. The maintainer's suggestion on the issue (bypass loading default config for the OAuth flow) is the real fix.Fix — two treatments matching the two kinds of call site
AppAWSSession,AdminAWSSession,GetCredentials) — these inject OAuth-derived static credentials / use web-identity federation and never need the local files. NewignoreSharedConfigFiles()load option disables shared config/credentials file loading. This eliminates the "auth works but nothing else does" failure.--aws-credentialspaths (app.Init,cmd/access.adminSession) — these read local config by design, so bypassing isn't an option. Newauth.FriendlyAWSConfigError()detects the "partial credentials" signature and appends a hint at the real, machine-local cause (original error preserved via%w).Verification
[default]profile and confirmed the shared-file bypass makes the static-cred path succeed.auth.FriendlyAWSConfigErrorunit-tested (nil passthrough, partial-cred hint,errors.Isunwrap, unrelated passthrough).go build ./...,go test ./auth/... ./app/... ./cmd/..., andgolangci-lint run ./auth/...clean (only pre-existing errcheck findings remain).