fix: entity null fetch produces resolver error#1379
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a pre-merge guard in mergeResult to skip merging when a subgraph returns null for an entity or entity-batch fetch via Changes
Sequence Diagram(s)Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
b6f2ad6 to
2715b7a
Compare
|
force pushed because I rebased this pr on top of main branch |
…oduces-fetch-error-no-data-or
…oduces-fetch-error-no-data-or
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
v2/pkg/engine/resolve/loader.go
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@v2/pkg/engine/resolve/loader.go`:
- Around line 642-643: Fix the typo in the doc comment for isEmptyEntityFetch:
change "sucessful" to "successful" in the comment above the isEmptyEntityFetch
function so the documentation reads "successful entity fetch".
…oduces-fetch-error-no-data-or
There was a problem hiding this comment.
🧹 Nitpick comments (1)
v2/pkg/engine/resolve/resolve_test.go (1)
2411-2482: Consider adding the missing batch+nullable root variant for symmetry.You covered batch null entity with a non-nullable root field, but the nullable-root equivalent is still untested in this block. Adding it would complete the behavior matrix and reduce regression risk.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v2/pkg/engine/resolve/resolve_test.go` around lines 2411 - 2482, Add a parallel test case to cover the "batch null entity with nullable root field" variant: copy the existing t.Run("fetch with null entity batch and non-nullable root field", ...) case but set the root Data.Nullable = true (the GraphQLResponse.Fetches SingleWithPath BatchEntityFetch -> Data Nullable field) and adjust the expectedOutput to the nullable-root expectation (e.g. no non-nullable error and the field value is null in the data JSON). Keep the same mock DataSource behavior (NewMockDataSource.Load returning {"data":{"_entities":[null]}}) and the same BatchEntityFetch config (SkipNullItems/SkipErrItems, SelectResponseDataPath, etc.) to verify the resolver returns a null field rather than an error when the root is nullable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@v2/pkg/engine/resolve/resolve_test.go`:
- Around line 2411-2482: Add a parallel test case to cover the "batch null
entity with nullable root field" variant: copy the existing t.Run("fetch with
null entity batch and non-nullable root field", ...) case but set the root
Data.Nullable = true (the GraphQLResponse.Fetches SingleWithPath
BatchEntityFetch -> Data Nullable field) and adjust the expectedOutput to the
nullable-root expectation (e.g. no non-nullable error and the field value is
null in the data JSON). Keep the same mock DataSource behavior
(NewMockDataSource.Load returning {"data":{"_entities":[null]}}) and the same
BatchEntityFetch config (SkipNullItems/SkipErrItems, SelectResponseDataPath,
etc.) to verify the resolver returns a null field rather than an error when the
root is nullable.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v2/pkg/engine/resolve/loader.gov2/pkg/engine/resolve/resolve_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- v2/pkg/engine/resolve/loader.go
|
Is there any chance this fix will be released soon? |
Yes, working on it |
…oduces-fetch-error-no-data-or
🤖 I have created a release *beep* *boop* --- ## [2.0.0-rc.270](v2.0.0-rc.269...v2.0.0-rc.270) (2026-04-09) ### Bug Fixes * entity null fetch produces resolver error ([#1379](#1379)) ([a753eb3](a753eb3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Checklist
Context
When the engine receives responses from subgraph entity fetches during resolving it currently does not differentiate between null data responses
{ "data": null }and null entity responses{ "data": { "_entities": [ null ] } }.In both cases the engine adds a
no data or errors in responseresolver error but this is not correct. In case of a null entity fetch the subgraph returned actual data: an array containing null elements. Instead of creating an error it should simply skip merging it into the result.Summary by CodeRabbit
Bug Fixes
Tests