Skip to content

Conversation

@jasontedor
Copy link
Member

Today we have a few problems with how we handle bad requests:

  • handling requests with bad encoding
  • handling requests with invalid value for filter_path/pretty/human
  • handling requests with a garbage Content-Type header

There are two problems:

  • in every case, we give an empty response to the client
  • in most cases, we leak the byte buffer backing the request!

These problems are caused by a broader problem: poor handling preparing the request for handling, or the channel to write to when the response is ready. This commit addresses these issues by taking a unified approach to all of them that ensures that:

  • we respond to the client with the exception that blew us up
  • we do not leak the byte buffer backing the request

Closes #21974, relates #28909

Today we have a few problems with how we handle bad requests:
 - handling requests with bad encoding
 - handling requests with invalid value for filter_path/pretty/human
 - handling requests with a garbage Content-Type header

There are two problems:
 - in every case, we give an empty response to the client
 - in most cases, we leak the byte buffer backing the request!

These problems are caused by a broader problem: poor handling preparing
the request for handling, or the channel to write to when the response
is ready. This commit addresses these issues by taking a unified
approach to all of them that ensures that:
 - we respond to the client with the exception that blew us up
 - we do not leak the byte buffer backing the request
@jasontedor jasontedor added >bug review :Distributed Coordination/Network Http and internode communication implementations v7.0.0 v6.3.0 labels Mar 26, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jasontedor
Copy link
Member Author

retest this please

@jasontedor
Copy link
Member Author

jasontedor commented Mar 27, 2018

@nik9000 @tbrooks8 This is ready for review now. 😌

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I don't know this code particularly well but it looks like an improvement to me. I think @tbrooks8 should also have a look. ❤️, thanks for fixing these! Leaking the byte buffer seems pretty bad!

@Tim-Brooks
Copy link
Contributor

Tim-Brooks commented Mar 28, 2018

I'll take a look today, I'd held off as I kept seeing new commits. Thanks for the ping.

Copy link
Contributor

@Tim-Brooks Tim-Brooks left a comment

Choose a reason for hiding this comment

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

LGTM.

@jasontedor jasontedor merged commit 4ef3de4 into elastic:master Mar 28, 2018
@jasontedor
Copy link
Member Author

I'll take a look today, I'd held off as I kept seeing new commits. Thanks for the ping.

Yeah sorry about all those pings. I was really unhappy with the first version of the PR when I woke up the next morning so had to push on it again to get it to a spot I was happy with. Thanks for reviewing.

jasontedor added a commit that referenced this pull request Mar 28, 2018
Today we have a few problems with how we handle bad requests:
 - handling requests with bad encoding
 - handling requests with invalid value for filter_path/pretty/human
 - handling requests with a garbage Content-Type header

There are two problems:
 - in every case, we give an empty response to the client
 - in most cases, we leak the byte buffer backing the request!

These problems are caused by a broader problem: poor handling preparing
the request for handling, or the channel to write to when the response
is ready. This commit addresses these issues by taking a unified
approach to all of them that ensures that:
 - we respond to the client with the exception that blew us up
 - we do not leak the byte buffer backing the request
@jasontedor jasontedor deleted the bad-rest-requests branch March 28, 2018 20:29
@jasontedor
Copy link
Member Author

Thanks for reviewing @nik9000 and @tbrooks8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Distributed Coordination/Network Http and internode communication implementations v6.3.0 v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants