Fix/multipart stray linebreak - #688
Merged
Vincent Biret (baywet) merged 2 commits intoAug 14, 2026
Merged
Conversation
|
Contributor
Author
|
@microsoft-github-policy-service agree |
Vincent Biret (baywet)
approved these changes
Aug 14, 2026
Vincent Biret (baywet)
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution!
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.



Overview
MultipartBody.serialize()writes every string part's value withwrite_str_value(),which always appends a trailing newline. That newline therefore becomes part of the value
Itself. E.g. A part meant to hold the value
"helloworld"is sent as"helloworld\r\n".Consumers that compare that value exactly would then reject it.
Fixed by writing string part values with
write_bytes_value()instead, which writes raw bytes with no terminator.Related Issue
Fixes #687
Demo
Before (current
main), atext/plainpart with value"Hello world":After (this PR):
Notes
bytes/file parts already go throughwrite_bytes_value()and never carried the stray CRLF.strpart before this PR, everytest_write_object_value*case used a JSON (Parsable) part and abytespart, nevera bare string one.
Testing Instructions
cd packages/serialization/multipart && poetry installpoetry run pytest** Expect
test_write_object_value_with_string_partandtest_write_object_value_with_multiple_string_partsto pass (both fail onmainwithout this fix (double CRLF before the boundary instead of one))