Skip to content

[Fusion] Handle non-multipart request when Upload scalar is optional#9514

Merged
tobias-tengler merged 1 commit intomainfrom
tte/fix-optional-upload
Apr 8, 2026
Merged

[Fusion] Handle non-multipart request when Upload scalar is optional#9514
tobias-tengler merged 1 commit intomainfrom
tte/fix-optional-upload

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 12:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 IFileLookup across 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 nullableUpload field 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants