-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Send REST response for incorrectly encoded url params #28909
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
Conversation
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
1 similar comment
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
33e5cdf to
ac967f1
Compare
|
cc @elastic/es-core-infra |
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the motivation for the change, but the technical implementation is not attractive to me. Mutating the request as is done here is not something we want to be in the business of. I am marking this as "Request changes" because I can not approve of this PR as-is.
| private final Set<String> consumedParams = new HashSet<>(); | ||
| private final SetOnce<XContentType> xContentType = new SetOnce<>(); | ||
|
|
||
| private Exception exception; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this mutable field (and thus making RestRequest not immutable) is not attractive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasontedor thanks!
Have another look ?
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left another comment; I continue to think that unless we can find a clean implementation here we let this one go.
| } | ||
| } | ||
| this.exception.set(parsingQueryStringException); | ||
| this.params = params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change still bothers me a lot. Again, I appreciate the motivation for it but the implementation that we are being forced into here leaves a lot to be desired (I am not faulting you for it, we are somewhat painted into a corner here). Another problem here is that now the object is a garbage state, we have no idea what the state of params is here yet we are allowing construction of this object to complete as if nothing happened. This is dangerous and I think that we should not do it.
|
I'd be tempted to make a checked exception that contains a RestRequest and throw it from the And when I type it out I realize that is fairly hairy, but it doesn't need any @jasontedor, I know my idea isn't great, but does it give you any ideas? I think we ought return something real to the user if we can get away with it. |
|
Thanks @nik9000; your comment has made me take a closer look, and I think there are more problems here that are going to require a holistic approach: if we blow up creating the channel (e.g., parsing |
|
Closing in favor of #29249. @jasontedor thanks for following up on this with a much more robust solution! |
Previously if the
pathcontained incorrectly encoded sequence, an error was returned :But if the incorrect sequence was part of the
parameters, no response was returned.This PR analyze the
parametersand returns an error when there is a wrong encoding sequence in the url params ( The errors are consistent with the ones returned for incorrectpath)Fixes : #21974