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

Default credentials provider should not fail silently if multiple HTTP client are present #4583

Closed
singhbaljit opened this issue Oct 12, 2023 · 7 comments
Assignees
Labels
bug This issue is a bug. closing-soon This issue will close in 4 days unless further comments are made. p2 This is a standard priority issue

Comments

@singhbaljit
Copy link

singhbaljit commented Oct 12, 2023

Describe the bug

Currently, if both the Apache and URL clients are present on classpath, WebIdentityTokenFileCredentialsProvider will fail with the expected error

Caused by: software.amazon.awssdk.core.exception.SdkClientException: Multiple HTTP implementations 
were found on the classpath. To avoid non-deterministic loading implementations, please explicitly provide 
an HTTP client via the client builders, set the software.amazon.awssdk.http.service.impl system property 
with the FQCN of the HTTP service to use as the default, or remove all but one HTTP implementation 
from the classpath

However, the default credentials provider ignores this error, and moves to the next credential provider. When such exception happens, it indicates that the SDK is configured incorrectly. Ignoring the error implies the STS credentials are not provided, which is not the expected behavior.

Expected Behavior

This error should either not be thrown or not ignored silently.

Current Behavior

Default credentials provider ignores the error WebIdentityTokenFileCredentialsProvider when multiple HTTP clients are present on classpath.

Reproduction Steps

  1. Use the default credentials provider to fetch credentials.
  2. Add the URL client module on classpath
  3. Provide configurations for WebIdentityTokenFileCredentialsProvider
  4. The error from WebIdentityTokenFileCredentialsProvider is ignored silently.

Possible Solution

  • Throw an exception if the WebIdentityTokenFileCredentialsProvider failed because of incorrect SDK usage with multiple clients.
  • Or define a HTTP client explicitly for the STS client so that this exception is not thrown.

Additional Information/Context

This came about when working with awslabs/aws-glue-schema-registry. That library, unlike this SDK, uses the URL client by default instead of the Apache client. See awslabs/aws-glue-schema-registry#120.

AWS Java SDK version used

2.20.162

JDK version used

17.0.8

Operating System and version

Any

@singhbaljit singhbaljit added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 12, 2023
@bhoradc bhoradc self-assigned this Oct 17, 2023
@bhoradc bhoradc removed the needs-triage This issue or PR still needs to be triaged. label Oct 17, 2023
@bhoradc
Copy link

bhoradc commented Oct 18, 2023

Hi @singhbaljit,

Thank you for reporting this issue.

I believe this behaviour is per the design. The behaviour of moving onto the next credential provider in the Default credentials provider chain is as expected. The Java SDK can't change its behaviour when there's more than one sync client in the classpath.

You would need to check the logs if an expected credential isn't picked up.

Please let me know if you have further questions. Thank you.

Regards,
Chaitanya

@bhoradc bhoradc added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Oct 18, 2023
@github-actions
Copy link

It looks like this issue has not been active for more than five days. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.

@github-actions github-actions bot added the closing-soon This issue will close in 4 days unless further comments are made. label Oct 23, 2023
@singhbaljit
Copy link
Author

At the INFO level, the default credentials provider actually does not state which underlying credentials provider is being used. So it is difficult to debug, especially in the Kubernetes/STS context. I think the default credentials provider should distinguish between "credentials not available" vs. "SDK is used improperly". Or the very least, print which credentials provider is being at the INFO level.

@singhbaljit
Copy link
Author

I created #4631.

@github-actions github-actions bot removed closing-soon This issue will close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. labels Oct 24, 2023
@bhoradc bhoradc added the needs-review This issue or PR needs review from the team. label Oct 26, 2023
@bhoradc bhoradc added the p2 This is a standard priority issue label Nov 9, 2023
@debora-ito debora-ito removed the needs-review This issue or PR needs review from the team. label Feb 20, 2024
@debora-ito
Copy link
Member

@singhbaljit we changed the behavior when multiple implementations are found in the classpath, WebIdentityTokenCredentialsProvider won't fail anymore after version 2.22.0, check my comment in #3555 (comment).

In addition, we don't think the logs should have a higher level than DEBUG in this case, so I'll close the PR you submitted.

Let us know if you have any questions.

@debora-ito debora-ito added the closing-soon This issue will close in 4 days unless further comments are made. label Feb 20, 2024
@singhbaljit
Copy link
Author

The changes did fix my issues. Thank you!

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closing-soon This issue will close in 4 days unless further comments are made. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants