Preserve delegate content type for multipart parameters#3382
Open
seonwooj0810 wants to merge 1 commit into
Open
Preserve delegate content type for multipart parameters#3382seonwooj0810 wants to merge 1 commit into
seonwooj0810 wants to merge 1 commit into
Conversation
`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>
velo
requested changes
Jun 3, 2026
Member
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.