Fix multipart/mixed serialization - only apply file descriptors for multipart/form-data#3778
Draft
Fix multipart/mixed serialization - only apply file descriptors for multipart/form-data#3778
Conversation
Co-authored-by: timovv <1787642+timovv@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix generated submitBatch body serializer for valid input
Fix multipart/mixed serialization - only apply file descriptors for multipart/form-data
Feb 18, 2026
timovv
reviewed
Feb 18, 2026
| (type.usage & UsageFlags.MultipartFormData) === UsageFlags.MultipartFormData | ||
| (type.usage & UsageFlags.MultipartFormData) === | ||
| UsageFlags.MultipartFormData && | ||
| hasMultipartProperties |
Member
There was a problem hiding this comment.
@copilot add a test case with multipart/mixed to verify the new behavior
Contributor
Author
There was a problem hiding this comment.
Added test case in test/modularUnit/scenarios/multipart/plainBody.md that verifies models without HttpPart<T> properties use default serialization instead of array-of-parts serialization. The test demonstrates that plain body models generate { body: item["body"] } rather than [createFilePartDescriptor(...)]. Commit: 29ade60
Co-authored-by: timovv <1787642+timovv@users.noreply.github.com>
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.
multipart/mixedbodies were incorrectly serialized as file descriptor arrays, breaking operations like Azure Storage'ssubmitBatchwhich expect plain string bodies.Root Cause
TCGC sets
UsageFlags.MultipartFormDatafor all multipart content types (multipart/mixed,multipart/form-data, etc.), but the emitter was applying file descriptor serialization unconditionally when this flag was present.Changes
Added property-level check in
buildSerializerFunction.tsto verifyserializationOptions.multipartexists before applying file descriptor serialization:Test Coverage
Added test case
plainBody.mdintest/modularUnit/scenarios/multipart/that verifies models withoutHttpPart<T>properties generate serializers with property mapping ({ body: item["body"] }) rather than array-of-parts serialization ([createFilePartDescriptor(...)]).Behavior
multipart/form-datawithHttpPart<T>: Properties haveserializationOptions.multipart→ generates[createFilePartDescriptor(...)]multipart/mixedwith plain body: Properties lack multipart options → generates property mapping instead of file descriptorsOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.