Skip to content

Conversation

@gniadeck
Copy link
Contributor

Motivation:

This is a fix for issue #13981 that reports a changed behaviour of HttpPostStandardRequestDecoder after this PR - #13908

Because HttpPostStandardRequestDecoder changed the contract, some code implementations relying on certain parsing are failing

Modification:

This PR makes sure, that the edge case handling for form body happenes only when the content is in fact form body

Result:

Fixes #13981

Motivation:

This is a fix for issue netty#13981 that reports a changed behaviour of HttpPostStandardRequestDecoder after this PR - netty#13908

Because HttpPostStandardRequestDecoder changed the contract, some code implementations relying on certain parsing are failing

Modification:

This PR makes sure, that the edge case handling for form data happenes only when the content is in fact form data

Result:

Fixes netty#13981
@gniadeck gniadeck requested a review from normanmaurer April 23, 2024 14:10
@gniadeck gniadeck requested a review from normanmaurer April 27, 2024 12:15
@normanmaurer normanmaurer merged commit a300058 into netty:4.1 Apr 27, 2024
@normanmaurer normanmaurer added this to the 4.1.110.Final milestone Apr 27, 2024
@normanmaurer
Copy link
Member

@gniadeck thanks!

normanmaurer pushed a commit that referenced this pull request Apr 27, 2024
Motivation:

This is a fix for issue #13981 that reports a changed behaviour of
HttpPostStandardRequestDecoder after this PR -
#13908

Because HttpPostStandardRequestDecoder changed the contract, some code
implementations relying on certain parsing are failing


Modification:

This PR makes sure, that the edge case handling for form body happenes
only when the content is in fact form body

Result:

Fixes #13981
LuciferYang pushed a commit to apache/spark that referenced this pull request May 28, 2024
### What changes were proposed in this pull request?
The pr aims to upgrade `netty` from `4.1.109.Final` to `4.1.110.Final`.

### Why are the changes needed?
- https://netty.io/news/2024/05/22/4-1-110-Final.html
  This version has brought some bug fixes and improvements, such as:
  Fix Zstd throws Exception on read-only volumes (netty/netty#13982)
  Add unix domain socket transport in netty 4.x via JDK16+ ([#13965](netty/netty#13965))
  Backport #13075: Add the AdaptivePoolingAllocator ([#13976](netty/netty#13976))
  Add no-value key handling only for form body ([#13998](netty/netty#13998))
  Add support for specifying SecureRandom in SSLContext initialization ([#14058](netty/netty#14058))

- https://github.com/netty/netty/issues?q=milestone%3A4.1.110.Final+is%3Aclosed

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Pass GA.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #46744 from panbingkun/SPARK-48420.

Authored-by: panbingkun <[email protected]>
Signed-off-by: yangjie01 <[email protected]>
@yawkat
Copy link
Contributor

yawkat commented Mar 3, 2025

@gniadeck can I ask what the use case is, here? I'm working on rewriting the post body parsing ( netty-contrib/codec-multipart#25 ), so I'd like to understand whether I need to support non-standard parsing like this

@yawkat
Copy link
Contributor

yawkat commented Mar 5, 2025

looking at the test for this PR, I'm not a big fan. It works by accident. Once your JSON has a = in it, it'll still be parsed as form data.

@chrisvest
Copy link
Member

@gniadeck Can you take a look at Jonas' comments?

@yawkat
Copy link
Contributor

yawkat commented Mar 19, 2025 via email

@gniadeck
Copy link
Contributor Author

hi, sorry for taking long to response, and thanks for considering our use case in your contributions :)

this fix was added simply to narrow the scope of the fix for multipart form body, to apply it only if the request has appropriate header. As I wrote in the original issue, when the bug was introduced, the JSON body was parsed as a name of MemoryAttribute, causing contract from previous releases to be broken. This also meant, that basically every body that didn't contain = would be parsed as an argument name with empty value

#13981

results in:
[Mixed: {    "netty": "reproduction"}=] on 4.1.109.Final and 4.1.108.Final

but results in:
[] on 4.1.107.Final and 4.1.106.Final

You're right, that in the current implementation adding = to JSON will split it and add it as parameters, and I think we could potentially rely more on the headers to determine the actual content of the body, rather than infering it by the content itself, since as shown in this example, it can be pretty tricky. The main usage of such behaviour, would be to see if the incoming POST request should be parsed as a parameter based one, or JSON based one

@yawkat
Copy link
Contributor

yawkat commented Mar 21, 2025

Yes, content sniffing is not the purpose of this class.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON in POST request treated as body attribute in HttpPostStandardRequestDecoder

4 participants