Skip to content

Fix projection crash on empty nested list sub-projection - #10066

Merged
glen-84 merged 2 commits into
mainfrom
gai/projection-list-instance-leak
Jul 8, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/projection-list-instance-leak

Conversation

@glen-84

@glen-84 glen-84 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Queryable projection threw ArgumentException: Property '...' is not defined for type 'List<T>' when a nested list's sub-projection was empty and a scalar sibling followed it. QueryableProjectionListHandler.OnBeforeEnter pushes an instance, but the empty-projection early-return in TryHandleLeave never popped it, so the trailing sibling bound against the leaked list instance.
  • The empty-projection branch now pops that instance, keeping the instance stack aligned with the parent scope, mirroring the non-empty path. This is the crash reported in UseProjection drops type-extension resolver fields (v16 regression) #10034.

Test plan

  • Added a projection integration test: a non-projectable extension field selected alone inside a nested list, followed by a sibling scalar; it now returns a well-formed result instead of throwing.
  • Data.Projections.Tests passes (156 tests).

Copilot AI review requested due to automatic review settings July 8, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a crash in queryable projections when a nested list’s sub-projection is empty by ensuring the list handler pops the instance it pushed on enter, keeping the projection context’s instance stack aligned for subsequent sibling selections.

Changes:

  • Pop the list instance in QueryableProjectionListHandler.TryHandleLeave when the list sub-projection is empty (prevents sibling scalar binding against the wrong instance).
  • Add an integration test covering the “empty nested list sub-projection + trailing sibling scalar” scenario reported in #10034.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionListHandler.cs Pops the pushed instance on the empty-projection early-return path to prevent instance-stack leakage and downstream binding crashes.
src/HotChocolate/Data/test/Data.Projections.Tests/IntegrationTests.cs Adds an integration test exercising the empty nested list sub-projection scenario with a trailing sibling scalar field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glen-84
glen-84 merged commit cc27fda into main Jul 8, 2026
277 of 285 checks passed
@glen-84
glen-84 deleted the gai/projection-list-instance-leak branch July 8, 2026 10:48
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