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

Feature/get missing alias json exception 301 #399

Conversation

szczepanczykd
Copy link
Collaborator

Description

Handling String error response from /_alias/not_existing_alias endpoint.

Add errorDeserializer to SimpleEndpoint constructor -> and use ErrorResponse._DESERIALIZER in every instance (except the GetAliasRequest._ENDPOINT) -> maybe two constructors would be better (one with default errorDeserializer)?

Created OpenSearchExceptionFactory -> thrown OpenSearchException is untouched.

API error response for GET https://localhost:9200/_alias/not_existing_alias (ErrorStringResponse format)
image

API error response for GET https://localhost:9200/not_existing_index/_search (ErrorResponse format)
image

Issues Resolved

#301

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.

…opensearch-project#301)

Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
…mpleEndpoint request (opensearch-project#301)

Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
…er (opensearch-project#301)

Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
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 OK to me. Made some smallish suggestions.

Should we open an issue in OpenSearch to not return a different response format in 3.0? This seems like an odd choice server-side. Are there other places where the server does this?

Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
@szczepanczykd
Copy link
Collaborator Author

Looks OK to me. Made some smallish suggestions.

Should we open an issue in OpenSearch to not return a different response format in 3.0? This seems like an odd choice server-side. Are there other places where the server does this?

I think yes, it seems it is only one case:
https://github.com/opensearch-project/OpenSearch/blob/8e0edee3d403e5f2339d176b800e9e5df1372692/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetAliasesAction.java

Lines: [160, 162]

Thanks for the review :)

@szczepanczykd szczepanczykd requested a review from dblock March 9, 2023 21:00
@dblock
Copy link
Member

dblock commented Mar 11, 2023

Looks OK to me. Made some smallish suggestions.
Should we open an issue in OpenSearch to not return a different response format in 3.0? This seems like an odd choice server-side. Are there other places where the server does this?

I think yes, it seems it is only one case: https://github.com/opensearch-project/OpenSearch/blob/8e0edee3d403e5f2339d176b800e9e5df1372692/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetAliasesAction.java

Lines: [160, 162]

Thanks for the review :)

Will you please do it?

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.

I have some nitpicky asks, the only must have is the license header update, we don't need the "modifications ..." part.

I think the rest of the code uses two spaces instead of 4/tabs? Mind checking and matching that. We should have some style checker/autoformatter do this and fail CI otherwise, too.

Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
@szczepanczykd
Copy link
Collaborator Author

I have some nitpicky asks, the only must have is the license header update, we don't need the "modifications ..." part.

I think the rest of the code uses two spaces instead of 4/tabs? Mind checking and matching that. We should have some style checker/autoformatter do this and fail CI otherwise, too.

The tests are using 4 spaces.
Rest of the code uses tabs.

@szczepanczykd
Copy link
Collaborator Author

Looks OK to me. Made some smallish suggestions.
Should we open an issue in OpenSearch to not return a different response format in 3.0? This seems like an odd choice server-side. Are there other places where the server does this?

I think yes, it seems it is only one case: https://github.com/opensearch-project/OpenSearch/blob/8e0edee3d403e5f2339d176b800e9e5df1372692/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetAliasesAction.java
Lines: [160, 162]
Thanks for the review :)

Will you please do it?

Done: opensearch-project/OpenSearch#6904

@szczepanczykd szczepanczykd requested a review from dblock March 30, 2023 18:58
@dblock
Copy link
Member

dblock commented Apr 3, 2023

Re-running flaky tests. Someone should look at those, wink wink :)

dblock
dblock previously approved these changes Apr 3, 2023
@reta
Copy link
Collaborator

reta commented Apr 3, 2023

Re-running flaky tests. Someone should look at those, wink wink :)

There is a fix suggested already #421

@dblock
Copy link
Member

dblock commented Apr 3, 2023

@reta I just merged that. Shall we just merge this one?

@reta
Copy link
Collaborator

reta commented Apr 3, 2023

@reta I just merged that. Shall we just merge this one?

@dblock the main is broken now (after opensearch-project/OpenSearch#6875), fixing it now

@VachaShah
Copy link
Collaborator

Hi @szczepanczykd, apologies for the delay! Can you merge the latest changes from main and fix the conflicts? We can get this merged once the CI is green.

@szczepanczykd
Copy link
Collaborator Author

szczepanczykd commented May 5, 2023 via email

Signed-off-by: Dominik Szczepanczyk <szczepanczyk.dominik@gmail.com>
@szczepanczykd
Copy link
Collaborator Author

Hi @szczepanczykd, apologies for the delay! Can you merge the latest changes from main and fix the conflicts? We can get this merged once the CI is green.

@VachaShah done :)

@reta
Copy link
Collaborator

reta commented May 5, 2023

@dblock @szczepanczykd @VachaShah I think this change is good but it does not follow the way we manage such API elements (when multiple forms are possible). Generally, it is done as a union (see for example https://github.com/opensearch-project/opensearch-java/blob/main/java-client/src/main/java/org/opensearch/client/opensearch/_types/Script.java#L164 but there are much more).

The way I would see it working is:

  • in both cases, the error is the same class ErrorResponse
  • but depending on the type (Object or String - solved by UnionDeserializer), it is either a full one or just stripped one with some part of the ErrorCause populated (like reason)

WDYT?

@szczepanczykd
Copy link
Collaborator Author

szczepanczykd commented May 5, 2023 via email

@szczepanczykd
Copy link
Collaborator Author

szczepanczykd commented May 10, 2023

@VachaShah @reta
I have created a new PR with a simpler approach to this issue :)
#476

@szczepanczykd
Copy link
Collaborator Author

Done in: #476

@szczepanczykd szczepanczykd deleted the feature/get-missing-alias-json-exception-301 branch May 11, 2023 15:24
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.

4 participants