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

Fix to return 401 instead of 500 #715

Merged
merged 2 commits into from
Dec 11, 2023
Merged

Fix to return 401 instead of 500 #715

merged 2 commits into from
Dec 11, 2023

Conversation

kathirsvn
Copy link
Contributor

What this PR does:

Fix to return 401 instead of 500 when invalid/token or credentials are provided

Which issue(s) this PR fixes:
Fixes #707

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@kathirsvn kathirsvn requested a review from a team as a code owner December 8, 2023 08:19
// credentials connecting to AstraDB throws IllegalArgumentException for invalid
// token/credentials
if (error instanceof AuthenticationException
|| (error instanceof IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, So IllegalArgumentException is the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct.

@tatu-at-datastax
Copy link
Contributor

Looks good in general.

One question: is there any way to be able to get errorCode to be added in CommandResult.Error returned? There are discussion with Client-side folks to be able to rely more on errorCode for classifying types of failures.
But as things are, only JsonApiException produces ErrorCode values.

I guess this is a bigger question and maybe not something to tackle for this PR, but I thought I'd mention it for future reference.

@kathirsvn
Copy link
Contributor Author

Looks good in general.

One question: is there any way to be able to get errorCode to be added in CommandResult.Error returned? There are discussion with Client-side folks to be able to rely more on errorCode for classifying types of failures. But as things are, only JsonApiException produces ErrorCode values.

I guess this is a bigger question and maybe not something to tackle for this PR, but I thought I'd mention it for future reference.

Agreed. We can discuss further on this in this new issue.

@kathirsvn kathirsvn merged commit 9539b85 into main Dec 11, 2023
3 checks passed
@kathirsvn kathirsvn deleted the auth_error_fix branch December 11, 2023 02:39
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.

401 instead of 500 for bad credentials
4 participants