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

[BUG] The RestController always consumes content when handling real HTTP requests #638

Closed
dbwiddis opened this issue Apr 2, 2024 · 0 comments · Fixed by #639
Closed
Assignees
Labels
bug Something isn't working v2.14.0

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Apr 2, 2024

What is the bug?

The BaseRestHandler includes a check whether content (the REST body) has been consumed by an API, throwing an exception here if it does not do so. This exception is tested in OpenSearch in a few places and we relied on it here for multiple APIs:

  • Get Workflow
  • Delete Workflow
  • Get Workflow State
  • Deprovision Workflow
  • Get Workflow Step

The reason for this check was that including a body would still execute the requested action but then fail to provide a proper REST result to the user. For the Get APIs this was mostly harmless, but deleting or deprovisioning a workflow would have side effects not reported to the user.

Unfortunately, it appears that these unit tests which rely on the behavior of the BaseRestHandler do not take into account the fact that the RestController always consumes content here when a REST request arrives via the HTTP handler.

How can one reproduce the bug?

Query any of the above APIs with a body in the request, for example

localhost:9200/_plugins/_flow_framework/workflow/any_id_here
{}

The result is:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_state_exception",
                "reason": "Channel is already closed"
            }
        ],
        "type": "illegal_state_exception",
        "reason": "Channel is already closed"
    },
    "status": 500
}

What is the expected behavior?

As intended: a 400 response with the message "request [GET /_plugins/_flow_framework/workflow/{workflow_id}] does not support having a body"

As implemented elsewhere in OpenSearch: silently ignored

Do you have any additional context?

This behavior has existed for at least 5 years but is undocumented/confusing. I'll be submitting a bug on the OpenSearch side reporting this, but the ideal fix (not consuming content) would potentially be seriously backwards incompatble with many scripts developed in the past 5 years.

In the meantime, we should not be sending null back to the Base Rest Handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2.14.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant