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] Be more clear on exception for empty request body #274

Closed
dbwiddis opened this issue Dec 11, 2023 · 0 comments · Fixed by #295
Closed

[FEATURE] Be more clear on exception for empty request body #274

dbwiddis opened this issue Dec 11, 2023 · 0 comments · Fixed by #295
Assignees
Labels
enhancement New feature or request

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Dec 11, 2023

Is your feature request related to a problem?

The OpenSearch BaseRestHandler throws an exception if content (the request body) is not consumed (request.content() is never called).

This creates a confusing situation in our code which doesn't require a body such as the provision and status APIs. Our code does throw an exception if there's no body, but the exception message we write is ignored and replaced by the BaseRestHandler's boilerplate.

What solution would you like?

One of the following:

  1. Inside the existing hasContent() checks, consume the content (call request.content()) to preserve our own error message, and throw a useful error message.
  2. Throw an empty exception without an error message that will be ignored to the existing catch block, and don't read the message there either.
  3. Immediately return from the method without bothering with exceptions.

Do you have any additional context?

We do need to check the content existence somehow (as we do), otherwise we'll actually perform the user's requested action but swallow the response message with a useless error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants