Repository navigation
Fix batched multipart uploads on the server and in the Fusion gateway - #10888
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical active issue can cause mixed-upload batches to omit the multipart map, so file markers may be sent incorrectly.
1 file not reviewed
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Generated file
What changed in this PR
This PR adds support for batched multipart uploads across Hot Chocolate servers and Fusion source-schema clients, including operation-indexed file maps and improved result mapping.
Changes:
- Supports indexed multipart paths, validates invalid batching combinations, and disposes parsed requests on rejection.
- Updates Fusion upload batching and result mapping for flattened, out-of-order, and single-operation batches.
- Adds server, Fusion, gateway, snapshot, documentation, and error-code coverage.
| File | Description |
|---|---|
| website/content/docs/hotchocolate/server/files.md | Documents batched multipart uploads and the new validation errors. |
| src/HotChocolate/Primitives/src/Primitives/ErrorCodes.cs | Defines the HC0141 and HC0142 multipart validation error codes. |
| src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Clients/HttpSourceSchemaClientTests.cs | Tests multipart construction for a single upload operation. |
| src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Clients/HttpSourceSchemaClientBufferedTests.cs | Tests Fusion upload batching, result mapping, ordering, errors, and single-request batches. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/FileUploadTests.cs | Adds gateway coverage for forwarding one file across multiple entity lookups. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/__snapshots__/FileUploadTests.Upload_Should_BindFile_When_LookupsForSeveralEntitiesShareTheFile.yaml | Captures the gateway and source-schema multipart interaction. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/ThrowHelper.cs | Removes obsolete flattened-index error handling. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/HttpSourceSchemaClient.ResultMapping.cs | Maps operation-batch results back to requests and variable sets. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/HttpSourceSchemaClient.cs | Passes request-body metadata to result mapping and constructs upload batches. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/HttpSourceSchemaClient.Buffered.cs | Applies the updated result-mapping logic to buffered execution. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Serialization/VariablePathTests.cs | Tests parsing and validation of operation-indexed variable paths. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests/Serialization/FileMapTrieTests.cs | Tests indexed paths, unindexed paths, and mixed-map rejection. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpMultipartMiddlewareTests.cs | Tests multipart batching, validation errors, disabled batching, and request disposal. |
| src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Utilities/ThrowHelper.cs | Adds exception helpers for multipart validation failures. |
| src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.resx | Adds localized messages for multipart validation errors. |
| src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs | Exposes generated accessors for the multipart validation resources. |
| src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Parsers/VariablePath.cs | Parses optional operation indexes from multipart variable paths. |
| src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/HttpMultipartMiddleware.cs | Applies indexed file maps to batched requests and disposes parsed requests on rejection. |
| src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/FileMapTrie.cs | Tracks indexed and unindexed paths and rejects mixed maps. |
| dictionary.txt | Adds the Unindexed terminology to the repository dictionary. |
Review effort: Lite
Contributor
Patch coverage96.5% of changed lines covered (164/170)
Uncovered changed lines (JSON){
"sha": "14879a16ab281ee8069460fef60272a639730593",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/HttpSourceSchemaClient.ResultMapping.cs", "ranges": [[100, 104], [107, 107]] }
]
}Project coverage: 59.8% (326997/546544 lines) |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active issues were identified, and the change is supported by comprehensive coverage across multipart parsing, validation, disposal, result mapping, gateway behavior, and documentation.
No open issues 🎉
1 resolved since last review
1 file not reviewed
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Generated file
Review effort: Lite
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.

Summary
{ "0": ["0.variables.file"], "1": ["1.variables.files.0"] }, so every operation of a batch can receive files. A map that mixes paths with and without an operation index is rejected withHC0141, and, when request batching is enabled, a batch of more than one operation whose paths have no index is rejected withHC0142. Every parsed operation is disposed when the request is rejected.requestIndex, so each entity gets its own result instead of the first one. Operation batch results are mapped byrequestIndexwhen they arrive out of order, and a batch that holds a single upload operation is sent as that operation with its own file map, so its file reaches the source schema.The
files.mddocs page describes batched uploads and the new error codes, and drops the outdated warning about uploads through a gateway.Test plan
HttpMultipartMiddlewareTests: the spec's batch example, a single operation sent as an array with and without an operation index,HC0141,HC0142, request batching disabled, and disposal of every parsed operation when a multipart request is rejected, tracked throughArrayPoolevents.VariablePathTestsandFileMapTrieTests: operation-indexed paths, invalid shapes, and mixed maps.HttpSourceSchemaClientBufferedTestsandHttpSourceSchemaClientTests: an upload request with several variable sets, an upload batch across requests, out-of-order results, a batch of one request, a whole-request error, and the parts sent for a batch with a single upload.FileUploadTests: through a gateway with a Hot Chocolate source schema, a file forwarded into lookups for two products returns each product's own result.AspNetCore.Tests,Fusion.Execution.Tests, andFusion.AspNetCore.Testspass in full.