Validate response parameters up-front (especially for chunked APIs) #93981
Labels
>bug
:Core/Infra/REST API
REST infrastructure and utilities
Team:Core/Infra
Meta label for core/infra team
The node stats API accepts a
?level=
query parameter which determines the level of detail in the response. This parameter is only used when serialising the response, it is not even validated up front. However, once we've started to serialize a chunked response we don't really have a way to handle an exception caused by a sudden discovery that one of the response parameters is invalid.This means that if you do
GET /_nodes/stats?level=invalid
you get an empty response and the following errors in the logs:In a sense the notion of "response parameter" is incompatible with a chunked API. We need to validate all the parameters up front, we cannot wait until response-serialisation time to do that. But even for non-chunked APIs it's pretty wasteful to do all the work to generate the response and then fail at response-serialisation time.
The text was updated successfully, but these errors were encountered: