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: catch 401 and 403 status and return proper error message #495

Merged

Conversation

chenqi0805
Copy link
Contributor

Description

This PR fixes the unclear 401 unauthorized exception by catching Json parsing exception.

Issues Resolved

Closes #494

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
@chenqi0805 chenqi0805 force-pushed the fix/494-catch-parsing-exception branch from aec3f73 to 20490fc Compare May 23, 2023 04:13
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Looks good, needs tests.

@chenqi0805 chenqi0805 changed the title FIX: catch parsing exception FIX: catch 401 and 403 status and return proper error message May 23, 2023
@chenqi0805 chenqi0805 force-pushed the fix/494-catch-parsing-exception branch from ce911c8 to ddf378b Compare May 23, 2023 20:50
Signed-off-by: George Chen <[email protected]>
@chenqi0805 chenqi0805 requested review from dblock and reta May 24, 2023 04:14
Signed-off-by: George Chen <[email protected]>
@chenqi0805 chenqi0805 force-pushed the fix/494-catch-parsing-exception branch from d7d4dbb to b834c4d Compare May 24, 2023 04:17
// The security plugin is required
Assume.assumeThat(isHttps(), equalTo(true));

final String userName = Optional.ofNullable(System.getProperty("user")).orElse("admin");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you don't even need credentialsProvider here

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

@reta you good with this?

@reta reta merged commit 004bb95 into opensearch-project:main May 30, 2023
@reta reta added the backport 2.x Backport to 2.x branch label May 30, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-495-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 004bb9595f21ecccea6914c050513aaad13d6612
# Push it to GitHub
git push --set-upstream origin backport/backport-495-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-495-to-2.x.

@reta
Copy link
Collaborator

reta commented May 30, 2023

@chenqi0805 seems like we need a manual backport to 2.x, would you take it please?

@chenqi0805
Copy link
Contributor Author

@reta I can try that. Could you also review the other related PR? #493

@chenqi0805
Copy link
Contributor Author

@reta Can you help me with manual backport? I got

git fetch
git worktree add ../.worktrees/backport-2.x 2.x
fatal: invalid reference: 2.x


@VachaShah
Copy link
Collaborator

VachaShah commented May 31, 2023

@chenqi0805 It shows that you don't have a local 2.x branch. You can either checkout a 2.x branch on your local or use the branch from upstream. Example:

git fetch
git worktree add ../.worktrees/backport-2.x upstream/2.x

@reta
Copy link
Collaborator

reta commented May 31, 2023

Thanks @VachaShah , @chenqi0805 if you still have difficulties, I could do backport for you, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Failing to connect to an OpenSearch cluster with a bad username/password gives unhelpful error
4 participants