[Fusion] Handle non-multipart request when Upload scalar is optional#9514
Merged
tobias-tengler merged 1 commit intomainfrom Apr 8, 2026
Merged
[Fusion] Handle non-multipart request when Upload scalar is optional#9514tobias-tengler merged 1 commit intomainfrom
tobias-tengler merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes handling of optional (Upload) file variables when the incoming request is not multipart (e.g., the variable is null), preventing failures caused by assuming a file lookup is always present.
Changes:
- Make file-upload detection tolerant to missing
IFileLookupacross Fusion variable coercion and downstream request construction. - Update Fusion and ASP.NET Core multipart middleware tests to cover nullable/optional upload variables with non-multipart requests.
- Extend test schemas/snapshots to include a
nullableUploadfield and validate both multipart and non-multipart behaviors.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/FileUploadTests.cs | Adds nullable upload coverage in Fusion tests and a nullable upload resolver. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_Single_File.yaml | Updates schema snapshot to include nullableUpload. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_Single_File_In_Input_Object.yaml | Updates schema snapshot to include nullableUpload. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_Single_File_In_Input_Object_Inline.yaml | Updates schema snapshot to include nullableUpload. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_Nullable_File.yaml | Adds snapshot covering multipart nullable upload. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_Nullable_File_Not_Provided.yaml | Adds snapshot covering non-multipart nullable upload with null variable. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_List_Of_Files.yaml | Updates schema snapshot to include nullableUpload. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_List_Of_Files_In_Input_Object.yaml | Updates schema snapshot to include nullableUpload. |
| src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/FileUploadTests.Upload_List_Of_Files_In_Input_Object_Inline.yaml | Updates schema snapshot to include nullableUpload. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/JsonVariableCoercion.cs | Avoids GetRequired<IFileLookup>() for Upload parsing when no lookup exists. |
| src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Clients/SourceSchemaHttpClient.cs | Only builds multipart/file-map requests when IFileLookup is present. |
| src/HotChocolate/Fusion/src/Fusion.Connectors.InMemory/InMemorySourceSchemaClient.cs | Only forwards IFileLookup feature when present. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpMultipartMiddlewareTests.cs | Adds tests ensuring optional/nullable uploads work when request is not multipart. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests/snapshots/HttpMultipartMiddlewareTests.Upload_Nullable_File.snap | Adds snapshot for nullable upload multipart test. |
| src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/UploadQuery.cs | Adds nullable upload resolver and makes optional upload resolver safely return null when not provided. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced May 1, 2026
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.
No description provided.