fix: incorrect alias behavior for required fields - #1604
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughFederation ChangesFederation Requires Planning and Execution
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ExecutionEngine
participant OwningHTTPSubgraph
participant GRPCProductsSubgraph
Client->>ExecutionEngine: execute federated operation
ExecutionEngine->>OwningHTTPSubgraph: fetch entity representations
OwningHTTPSubgraph-->>ExecutionEngine: return entities and key fields
ExecutionEngine->>GRPCProductsSubgraph: resolve `@requires` fields
GRPCProductsSubgraph-->>ExecutionEngine: return required results
ExecutionEngine-->>Client: return combined response or propagated error
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Claude Code Review
Claude Code Review is paused for this repository. To reconnect it, an admin of this repository's GitHub organization (or the account owner, for personal repositories) who can also manage your Claude organization's Code Review settings needs to re-link GitHub in Code Review settings. This is a one-time step.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor_federation.go (1)
440-467: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winCloned entry's fields get overwritten by stale data —
requiredFieldlocal var never repointed to the clone.In the
elsebranch (append-clone path),requiredField.clone()is appended intoconfig.requiredFields, but the localrequiredFieldvariable is never reassigned to that clone — it still holds the previously-bound entry. The subsequent lines (requiredField.ref = ref,.fieldDefRef = fieldDefRef,.resultField = field) mutate this stale value, andfieldArgumentsis only overwritten when the current occurrence has arguments (len(fieldArgs) > 0). If the current (aliased) occurrence has no arguments while the previously-bound entry did, the stalefieldArgumentsleaks into the newly appended entry at line 467, silently overwriting the intentionally-cleared clone.Example:
nullableFilteredTagSummary(prefix: $prefix)plus an aliased selection of the same field without the argument would send the wrong (stale)prefixargument for the aliased required-fields call.🐛 Proposed fix
} else { index = len(config.requiredFields) - config.requiredFields = append(config.requiredFields, requiredField.clone()) + requiredField = requiredField.clone() + config.requiredFields = append(config.requiredFields, requiredField) r.entityConfig.setEntity(r.entityInfo.typeName, config) }Consider adding a regression test (e.g. in
execution_plan_requires_test.go) combining an aliased selection with a field that has optional arguments, to catch this class of bug.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor_federation.go` around lines 440 - 467, In the clone branch of the required-field handling logic, repoint the requiredField local variable to the newly appended clone and update index accordingly before mutating ref, fieldDefRef, resultField, and fieldArguments. Ensure each response-key entry starts with the clone’s cleared argument state when the current occurrence has no arguments, preventing stale arguments from the previously bound entry from being copied.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor_federation.go`:
- Around line 440-467: In the clone branch of the required-field handling logic,
repoint the requiredField local variable to the newly appended clone and update
index accordingly before mutating ref, fieldDefRef, resultField, and
fieldArguments. Ensure each response-key entry starts with the clone’s cleared
argument state when the current occurrence has no arguments, preventing stale
arguments from the previously bound entry from being copied.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b6cac6bd-a5ec-476f-ba15-d06bf8261d65
📒 Files selected for processing (4)
v2/pkg/engine/datasource/grpc_datasource/execution_plan.gov2/pkg/engine/datasource/grpc_datasource/execution_plan_requires_test.gov2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor_federation.gov2/pkg/engine/datasource/grpc_datasource/grpc_datasource_federation_test.go
This PR adds tests and reformats the logic for planning required fields in connect @coderabbitai summary ## Checklist - [ ] I have discussed my proposed changes in an issue and have received approval to proceed. - [ ] I have followed the coding standards of the project. - [ ] Tests or benchmarks have been added or updated. ## Open Source AI Manifesto This project follows the principles of the [Open Source AI Manifesto](https://human-oss.dev). Please ensure your contribution aligns with its principles. <!-- Please add any additional information or context regarding your changes here. -->
…-fields-is-misbehaving
🤖 I have created a release *beep* *boop* --- ## [2.14.1](v2.14.0...v2.14.1) (2026-07-22) ### Bug Fixes * incorrect alias behavior for required fields ([#1604](#1604)) ([5752e91](5752e91)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: wundergraph-bot[bot] <285992168+wundergraph-bot[bot]@users.noreply.github.com>
Aliases are not correctly taken into accoutn when using required fields. This PR fixes the behavior.
@coderabbitai summary
Checklist
Open Source AI Manifesto
This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.