Fix internal projection selections leaking into the response - #9978
#9978Fix internal projection selections leaking into the response#9978
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a correctness issue where execution-engine-internal projection selections (for example _combinedSelectionSet, __projection_alias_N) could leak into the client-facing response via null-propagation and/or surfaced errors. It ensures internal selections are treated as fully internal across their subtrees and that their errors and nulls are contained.
Changes:
- Propagate “internal” status down the selection subtree during operation compilation so nested selections under an internal selection are also internal.
- Treat internal result elements as nullable to prevent null-propagation from internal selections affecting the client response, and suppress reporting errors for internal selections.
- Add regression tests for projection + authorization interactions and update related snapshots; add required test project reference.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Data/test/Data.Tests/ProjectionAuthorizationTests.cs | Adds regression tests ensuring internal projection selections neither surface data nor errors unless explicitly selected by the client. |
| src/HotChocolate/Data/test/Data.Tests/HotChocolate.Data.Tests.csproj | Adds a project reference needed for authorization types used in the new tests. |
| src/HotChocolate/Core/test/Execution.Tests/Processing/snapshots/OperationCompilerTests.Field_Based_Optimizers.snap | Updates snapshot to reflect internal propagation changes in compiled operations. |
| src/HotChocolate/Core/src/Types/Text/Json/ResultElement.cs | Treats internal selections as nullable to contain null/error propagation. |
| src/HotChocolate/Core/src/Types/Execution/Processing/OperationCompiler.cs | Ensures “internal” status is inherited by nested selections during compilation. |
| src/HotChocolate/Core/src/Types/Execution/Processing/MiddlewareContext.Global.cs | Suppresses client-facing error reporting for internal selections to prevent leakage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage in the Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
Fixes #9939