Skip to content

Fix Unexpected Execution Error when entity lookup returns null - #9991

Merged
michaelstaib merged 3 commits into
mainfrom
mst/null-lookup-fix
Jun 26, 2026
Merged

michaelstaib merged 3 commits into
mainfrom
mst/null-lookup-fix

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 26, 2026 14:25

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

This PR addresses a Fusion execution edge case where an entity lookup returning null could surface an “Unexpected Execution Error”, by treating a clean null lookup result as a valid “not found” state and completing fields using normal GraphQL nullability semantics.

Changes:

  • Update result completion to handle a null source without an associated error by completing each selected field (triggering standard non-null violations where applicable) rather than emitting a generic execution error.
  • Add coverage for nested entity lookups that resolve to null, including both non-null and nullable parent-field scenarios, with new snapshots.
  • (Unrelated / problematic) Add external worktree project references to src/All.slnx that appear to be machine-local paths.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/LookupTests.cs Adds new lookup tests covering entity lookup returning null for nested entities.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/LookupTests.Lookup_Should_Return_Null_When_Nested_Entity_Not_Found.yaml Snapshot for the non-null parent-field case (expects non-null violation instead of unexpected execution error).
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/LookupTests.Lookup_Should_Null_Field_When_Nullable_Entity_Not_Found.yaml Snapshot for the nullable parent-field case (field nulling + error semantics captured).
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Implements per-field completion behavior for clean null sources without errors.
src/All.slnx Adds machine-local ../.claude/worktrees/... projects (should be removed).

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

Comment thread src/All.slnx Outdated
Comment on lines +463 to +479
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/examples/PostgresTransport/PostgresTransport.AppHost/PostgresTransport.AppHost.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/examples/PostgresTransport/PostgresTransport.Contracts/PostgresTransport.Contracts.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/examples/PostgresTransport/PostgresTransport.NotificationService/PostgresTransport.NotificationService.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/examples/PostgresTransport/PostgresTransport.OrderService/PostgresTransport.OrderService.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/examples/PostgresTransport/PostgresTransport.ServiceDefaults/PostgresTransport.ServiceDefaults.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/examples/PostgresTransport/PostgresTransport.ShippingService/PostgresTransport.ShippingService.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/MediatorShowcase/MediatorShowcase.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/Middleware/UnitOfWork/UnitOfWork.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/Observability/OpenTelemetry/OpenTelemetryExample.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/Reliability/CircuitBreaker/CircuitBreaker.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/Reliability/OutboxInbox/OutboxInbox.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/Transports/MultiTransport/MultiTransport.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Examples/Transports/RabbitMQ/RabbitMQ.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Abstractions/Mocha.Abstractions.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Analyzers/Mocha.Analyzers.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Mocha.EntityFrameworkCore.Postgres.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.EntityFrameworkCore/Mocha.EntityFrameworkCore.csproj" />
Comment thread src/All.slnx Outdated
Comment on lines +480 to +494
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Hosting/Mocha.Hosting.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Inbox/Mocha.Inbox.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Mediator.Abstractions/Mocha.Mediator.Abstractions.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Mediator/Mocha.Mediator.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Outbox/Mocha.Outbox.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Threading/Mocha.Threading.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Transport.InMemory/Mocha.Transport.InMemory.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Transport.Postgres/Mocha.Transport.Postgres.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Transport.RabbitMQ/Mocha.Transport.RabbitMQ.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha.Utilities/Mocha.Utilities.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/src/Mocha/src/Mocha/Mocha.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/templates/azure-function/HotChocolate.Template.AzureFunctions.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/templates/gateway/HotChocolate.Template.Gateway.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/templates/HotChocolate.Templates.csproj" />
<Project Path="../.claude/worktrees/agent-a89bf9078d0222525/templates/server/HotChocolate.Template.Server.csproj" />
Comment on lines +145 to +146
[Fact]
public async Task Lookup_Should_Return_Null_When_Nested_Entity_Not_Found()
Comment on lines +186 to +188
[Fact]
public async Task Lookup_Should_Null_Field_When_Nullable_Entity_Not_Found()
{
@github-actions

github-actions Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

30.7% of changed lines covered (31/101)

File Covered Changed Patch %
…/Fusion/test/Fusion.AspNetCore.Tests/LookupTests.cs 0 68 0.0% 🔴
…/src/Fusion.Execution/Execution/Results/ValueCompletion.cs 31 33 93.9% 🟡
Uncovered changed lines (JSON)
{
  "sha": "552f55c9817ae7034fb337ce6caebc2f3083afa8",
  "files": [
    { "path": "src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/LookupTests.cs", "ranges": [[147, 147], [149, 151], [153, 155], [157, 161], [164, 164], [166, 175], [177, 180], [183, 184], [188, 188], [190, 192], [194, 196], [198, 202], [205, 205], [207, 216], [218, 221], [224, 225], [366, 366], [369, 369], [374, 374], [380, 380], [387, 387], [402, 402], [405, 405], [410, 410], [416, 416], [423, 423]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs", "ranges": [[350, 351]] }
  ]
}

Project coverage: 49.3% (217292/440360 lines)

@michaelstaib
michaelstaib merged commit 6f93fc1 into main Jun 26, 2026
143 checks passed
@michaelstaib
michaelstaib deleted the mst/null-lookup-fix branch June 26, 2026 14:36
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