Preserve delegate content type for multipart parameters#3382
Preserve delegate content type for multipart parameters#3382seonwooj0810 wants to merge 2 commits into
Conversation
velo
left a comment
There was a problem hiding this comment.
Thanks for the focused fix and for adding coverage around the delegated part content type. I cannot approve this while the required CI check is failing.\n\nGate results:\n1) Test coverage: PASS.\n2) Backwards compatibility: PASS.\n3) Security: PASS.\n\nBlocking issue:\n- Required check is currently failing for this PR. Please get the build green before this can be approved or merged.
38d942f to
789f3ef
Compare
|
Thanks for the review @velo. The failing |
|
Quick follow-up: CI is now fully green on the rebased branch — |
velo
left a comment
There was a problem hiding this comment.
Thanks for the update. The new regression tests cover both delegated content-type propagation and the existing fallback; the change preserves the protected write path and public behavior, and introduces no security issue. Required checks are green. The branch still conflicts with the base branch, so it cannot be merged until the conflict is resolved.
`DelegateWriter` encodes a parameter through the delegate `Encoder` (e.g. the Jackson encoder), which sets the correct `Content-Type` (such as `application/json`) on the throwaway `RequestTemplate`. That header was discarded and `SingleParameterWriter` hard-coded `text/plain`, so JSON parts of a multipart request were emitted as `text/plain`. `DelegateWriter` now reads the `Content-Type` produced by the delegate and passes it through to `SingleParameterWriter.writeWithContentType`, falling back to `text/plain; charset=<charset>` when the delegate sets no content type. The previous behaviour for plain single parameters is unchanged. Fixes OpenFeign#2813 Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
789f3ef to
ba1cf15
Compare
|
Thanks for the approval @velo. I've rebased the branch onto the latest |
|
The current While reproducing this locally I noticed the rebased |
velo
left a comment
There was a problem hiding this comment.
Thanks for adapting the regression test to the current Request.Body API. The test coverage, backwards-compatibility, and security gates pass, but the required ci/circleci: pr-build check is failing, so this cannot be approved or merged until CI is green.
|
To unblock the CI gate here, I've opened #3406 fixing the |
Fixes #2813
Problem
When a multipart request contains a POJO/JSON part,
DelegateWriterencodes the value through the delegateEncoder(e.g. the Jackson encoder), which correctly setsContent-Type: application/jsonon the throwawayRequestTemplate. That header was then discarded, andSingleParameterWriterhard-codedContent-Type: text/plain. As a result, JSON parts were emitted astext/plaininstead ofapplication/json(see the report in #2813).Change
DelegateWriternow reads theContent-Typeproduced by the delegate and forwards it to a newSingleParameterWriter.writeWithContentType(output, key, value, contentType)method.text/plain; charset=<charset>behaviour, so plain single parameters are unaffected.write(output, key, value)template method is preserved and simply delegates with anullcontent type.Tests
Added
feign.form.multipart.DelegateWriterTest:usesContentTypeFromDelegate— asserts a delegate that setsapplication/jsonproducesContent-Type: application/json(and nottext/plain).fallsBackToTextPlainWhenDelegateSetsNoContentType— asserts thetext/plain; charset=UTF-8fallback when the delegate sets no content type.Test evidence
Ran the
formmodule test suite (and its upstream dependencies) locally:Verification done: confirmed the hard-coded
text/plainstill present onmasterinSingleParameterWriter#write; confirmed no in-flight PR referencing the issue and no active self-claim (maintainer invited a PR with tests on 2026-05-27); fix touches only.javafiles; fullformmodule test suite passes after the change.