Skip to content

Friendlier handling of incomplete local AWS credentials#159

Open
blsmth wants to merge 1 commit into
mainfrom
friendlier-aws-creds-error-155
Open

Friendlier handling of incomplete local AWS credentials#159
blsmth wants to merge 1 commit into
mainfrom
friendlier-aws-creds-error-155

Conversation

@blsmth

@blsmth blsmth commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Closes #155.

Problem

With a partially-configured default profile (or stray AWS_* env vars), every command except apppack auth failed with the raw SDK error:

error fetching config from profile, default, Error using profile:
 2, partial credentials found for profile default

auth worked because it's a pure OAuth flow; everything else calls LoadDefaultConfig, which eagerly loads and validates the local ~/.aws files 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 via WithCredentialsProvider — 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

  1. OAuth paths (AppAWSSession, AdminAWSSession, GetCredentials) — these inject OAuth-derived static credentials / use web-identity federation and never need the local files. New ignoreSharedConfigFiles() load option disables shared config/credentials file loading. This eliminates the "auth works but nothing else does" failure.
  2. --aws-credentials paths (app.Init, cmd/access.adminSession) — these read local config by design, so bypassing isn't an option. New auth.FriendlyAWSConfigError() detects the "partial credentials" signature and appends a hint at the real, machine-local cause (original error preserved via %w).

Verification

  • Reproduced the failure against a partial [default] profile and confirmed the shared-file bypass makes the static-cred path succeed.
  • auth.FriendlyAWSConfigError unit-tested (nil passthrough, partial-cred hint, errors.Is unwrap, unrelated passthrough).
  • go build ./..., go test ./auth/... ./app/... ./cmd/..., and golangci-lint run ./auth/... clean (only pre-existing errcheck findings remain).

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Friendlier error when local AWS credentials are incomplete

1 participant