Skip to content

Preserve AWS_CREDENTIALS during auth scheme resolution#6926

Merged
S-Saranya1 merged 2 commits intofeature/master/core-interceptors-migrationfrom
somepal/fix-endpoint-npe-and-support-aws-credentials
Apr 30, 2026
Merged

Preserve AWS_CREDENTIALS during auth scheme resolution#6926
S-Saranya1 merged 2 commits intofeature/master/core-interceptors-migrationfrom
somepal/fix-endpoint-npe-and-support-aws-credentials

Conversation

@S-Saranya1
Copy link
Copy Markdown

@S-Saranya1 S-Saranya1 commented Apr 30, 2026

Motivation and Context

Previously some customers override AWS credentials for specific requests by setting AwsSignerExecutionAttribute.AWS_CREDENTIALS in their execution interceptors. After moving auth scheme resolution from interceptors to a dedicated pipeline stage (#6755), these interceptor-set credentials were being ignored.

This happened because after moving auth scheme resolution to a pipeline stage, credentials are now freshly resolved in AuthSchemeResolutionStage. Since this stage runs after all interceptors, the freshly resolved credentials replace whatever the interceptor had set via AWS_CREDENTIALS.

Modifications

Fix 1:

Updated IdentityProviderUpdater to accept ExecutionAttributes and check for interceptor-set AWS_CREDENTIALS before resolving credentials. If an interceptor has set credentials, they are wrapped in a StaticCredentialsProvider and used instead of the default provider.

Credentials are resolved in this priority order:

  1. Request-level override via AwsRequestOverrideConfiguration.credentialsProvider()(Not respected before, this refactoring fixes it)
  2. Interceptor-set AwsSignerExecutionAttribute.AWS_CREDENTIALS (deprecated, preserved for backwards compatibility)
  3. Client-configured credentials provider (default)

This matches the behavior before the migration.

Changes:

  • IdentityProviderUpdater — added executionAttributes parameter to the update method
  • AwsIdentityProviderUpdater — added check for deprecated AWS_CREDENTIALS execution attribute
  • AuthSchemeResolutionStage — passes execution attributes to the updater
  • EndpointResolutionStage — null-safe port comparison in interceptorModifiedEndpoint

Fix 2 : Fixed NPE in EndpointResolutionStage on null port

Fixed a NullPointerException in EndpointResolutionStage when comparing request ports. The port can be null when no explicit port is set, and the comparison was not null-safe.

Testing

Verified with existing unit test in IdentityResolutionOverrideTest which covers credential override scenarios including interceptor-set AWS_CREDENTIALS, request-level overrides, and default credentials provider fallback.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

…-set AWS_CREDENTIALS during auth scheme resolution
@S-Saranya1 S-Saranya1 requested a review from a team as a code owner April 30, 2026 19:00
@S-Saranya1 S-Saranya1 changed the title Fix EndpointResolutionStage NPE on null port and preserve interceptor… Preserve interceptor-set AWS_CREDENTIALS during auth scheme resolution Apr 30, 2026
@S-Saranya1 S-Saranya1 changed the title Preserve interceptor-set AWS_CREDENTIALS during auth scheme resolution Preserve AWS_CREDENTIALS during auth scheme resolution Apr 30, 2026
&& (!requestHost.equals(preModifyUri.getHost())
|| !String.valueOf(request.protocol()).equals(preModifyUri.getScheme())
|| request.port() != preModifyUri.getPort());
|| (requestPort != null && requestPort != preModifyUri.getPort()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be replaced with Objects.equals()?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, when no port is set, the SDK returns null but URI.getPort() returns -1, so Objects.equals() would be incorrect and needs special handling for this when no port is set case. So just skipping the comparison when port is null.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see!

@S-Saranya1 S-Saranya1 merged commit 21e089f into feature/master/core-interceptors-migration Apr 30, 2026
13 of 30 checks passed
@github-actions
Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants