Conversation
Just to ensure a clean diff of what really changes once the grpctest SDL changes.
📝 WalkthroughWalkthroughPropagates GraphQL field arguments from federation Changes
Sequence Diagram(s)sequenceDiagram
participant Client as GraphQL Client
participant Planner as Federation Planner
participant Visitor as Visitor
participant Executor as Execution Plan Executor
participant Compiler as gRPC Compiler
participant gRPCService as gRPC Service
Client->>Planner: Request `@requires` field with arguments
Planner->>Visitor: process required field
Visitor->>Visitor: parseFieldArguments() -> attach to requiredField
Visitor->>Executor: emit execution plan (includes fieldArguments)
Executor->>Executor: createRequiredFieldsRPCCall() (include field_args if present)
Executor->>Compiler: buildRequiredFieldsMessage(request with field_args)
Compiler->>Compiler: locate `field_args` in RPC schema
Compiler->>Compiler: buildProtoMessage() & setMessageValue()
Executor->>gRPCService: call RPC with context + field_args
gRPCService->>gRPCService: read field_args, compute filtered summary
gRPCService-->>Executor: return response results
Executor-->>Client: resolve `@requires` field
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
v2/pkg/grpctest/mockservice_requires.go (1)
303-321: Handle non-positivemaxResultsexplicitly in multi-prefix filtering.At Line 319, the cap check uses equality only. For negative values, the cap is effectively disabled, which is surprising for a “max results” contract.
♻️ Suggested refinement
func (s *MockService) RequireStorageMultiFilteredTagSummaryById(_ context.Context, req *productv1.RequireStorageMultiFilteredTagSummaryByIdRequest) (*productv1.RequireStorageMultiFilteredTagSummaryByIdResponse, error) { prefixes := req.GetFieldArgs().GetPrefixes() maxResults := int(req.GetFieldArgs().GetMaxResults()) results := make([]*productv1.RequireStorageMultiFilteredTagSummaryByIdResult, 0, len(req.GetContext())) for _, ctx := range req.GetContext() { + if maxResults <= 0 { + results = append(results, &productv1.RequireStorageMultiFilteredTagSummaryByIdResult{}) + continue + } tags := ctx.GetFields().GetTags() filteredTags := make([]string, 0, len(tags)) for _, tag := range tags { for _, p := range prefixes { if strings.HasPrefix(tag, p) { filteredTags = append(filteredTags, tag) break } } - if len(filteredTags) == maxResults { + if len(filteredTags) >= maxResults { break } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v2/pkg/grpctest/mockservice_requires.go` around lines 303 - 321, In RequireStorageMultiFilteredTagSummaryById, normalize the requested maxResults and make the cap check robust: read maxResults := int(req.GetFieldArgs().GetMaxResults()), if maxResults <= 0 set maxResults = 0 (treat non-positive as zero) and replace the equality cap check with a >= guard that only applies when maxResults > 0 (e.g. if maxResults > 0 && len(filteredTags) >= maxResults { break }), so negative values no longer disable the cap and the loop behaves predictably; update references to prefixes, filteredTags and maxResults in the filtering loop accordingly.
🤖 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/grpctest/mockservice_requires.go`:
- Around line 303-321: In RequireStorageMultiFilteredTagSummaryById, normalize
the requested maxResults and make the cap check robust: read maxResults :=
int(req.GetFieldArgs().GetMaxResults()), if maxResults <= 0 set maxResults = 0
(treat non-positive as zero) and replace the equality cap check with a >= guard
that only applies when maxResults > 0 (e.g. if maxResults > 0 &&
len(filteredTags) >= maxResults { break }), so negative values no longer disable
the cap and the loop behaves predictably; update references to prefixes,
filteredTags and maxResults in the filtering loop accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2f71adf9-0545-407a-82bc-66cff6012a5a
⛔ Files ignored due to path filters (2)
v2/pkg/grpctest/productv1/product.pb.gois excluded by!**/*.pb.gov2/pkg/grpctest/productv1/product_grpc.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (10)
v2/pkg/engine/datasource/grpc_datasource/compiler.gov2/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.gov2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.gov2/pkg/grpctest/mapping/mapping.gov2/pkg/grpctest/mockservice_requires.gov2/pkg/grpctest/product.protov2/pkg/grpctest/testdata/products.graphqls
…ield-resolvers-in-go-tools
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/grpctest/mockservice_requires.go`:
- Around line 495-496: The loop that appends into filteredTags only breaks when
len(filteredTags) == maxResults, which allows results when maxResults <= 0;
update the logic in the function that builds filteredTags to first treat
non-positive maxResults as returning no matches (e.g., if maxResults <= 0 return
empty slice), and change the break condition to use >= (if len(filteredTags) >=
maxResults) to ensure we never exceed the cap; adjust the code paths that
reference filteredTags and maxResults accordingly (look for the loop appending
to filteredTags and the variables filteredTags and maxResults).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7fd88360-f35e-486d-b1a7-bc1ba2812c07
⛔ Files ignored due to path filters (2)
v2/pkg/grpctest/productv1/product.pb.gois excluded by!**/*.pb.gov2/pkg/grpctest/productv1/product_grpc.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (10)
v2/pkg/engine/datasource/grpc_datasource/compiler.gov2/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.gov2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.gov2/pkg/grpctest/mapping/mapping.gov2/pkg/grpctest/mockservice_requires.gov2/pkg/grpctest/product.protov2/pkg/grpctest/testdata/products.graphqls
✅ Files skipped from review due to trivial changes (2)
- v2/pkg/engine/datasource/grpc_datasource/execution_plan.go
- v2/pkg/engine/datasource/grpc_datasource/grpc_datasource_federation_test.go
🚧 Files skipped from review as they are similar to previous changes (6)
- v2/pkg/grpctest/mapping/mapping.go
- v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor_federation.go
- v2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.go
- v2/pkg/engine/datasource/grpc_datasource/execution_plan_requires_test.go
- v2/pkg/grpctest/product.proto
- v2/pkg/engine/datasource/grpc_datasource/compiler.go
There was a problem hiding this comment.
♻️ Duplicate comments (1)
v2/pkg/grpctest/mockservice_requires.go (1)
484-497:⚠️ Potential issue | 🟡 MinorHandle non-positive
maxResultsbefore filtering.At Line 495, the cap check runs after append, so
maxResults <= 0can still emit one match when the first tag passes the prefix filter.Proposed fix
for _, ctx := range req.GetContext() { + if maxResults <= 0 { + results = append(results, &productv1.RequireStorageMultiFilteredTagSummaryByIdResult{ + MultiFilteredTagSummary: nil, + }) + continue + } + tags := ctx.GetFields().GetTags() filteredTags := make([]string, 0, len(tags)) for _, tag := range tags { for _, p := range prefixes { if strings.HasPrefix(tag, p) { filteredTags = append(filteredTags, tag) break } } if len(filteredTags) >= maxResults { break } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v2/pkg/grpctest/mockservice_requires.go` around lines 484 - 497, The loop that builds filteredTags incorrectly allows a match when maxResults <= 0 because the cap is checked only after appending; before iterating tags (inside the context loop where req.GetContext() is handled), add an early guard that if maxResults <= 0 then skip filtering (e.g., continue) or set filteredTags to empty and skip further work for that context so no tags are appended; ensure the check on maxResults happens before any append to filteredTags in the code that uses tags, prefixes, and filteredTags.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@v2/pkg/grpctest/mockservice_requires.go`:
- Around line 484-497: The loop that builds filteredTags incorrectly allows a
match when maxResults <= 0 because the cap is checked only after appending;
before iterating tags (inside the context loop where req.GetContext() is
handled), add an early guard that if maxResults <= 0 then skip filtering (e.g.,
continue) or set filteredTags to empty and skip further work for that context so
no tags are appended; ensure the check on maxResults happens before any append
to filteredTags in the code that uses tags, prefixes, and filteredTags.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cb179f90-b3e1-4879-ac5f-5d2e3722a36b
📒 Files selected for processing (1)
v2/pkg/grpctest/mockservice_requires.go
🤖 I have created a release *beep* *boop* --- ## [2.0.0-rc.268](v2.0.0-rc.267...v2.0.0-rc.268) (2026-04-07) ### Features * add support for fields with arguments and requires directive ([#1452](#1452)) ([58469c3](58469c3)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Context
A change in protographic allows to treat fields with arguments to be treated as a required fields alongside needed protobuf rpc's and message to retrieve field_arguments. A necessary change to allow field arguments on
@requiresfields.When giving this new proto spec and mapping to the engine such fields were silently ignoring the arguments — the gRPC call received the context (key + required fields) but no
field_args, so the service always saw zero-value arguments.Implementation
Wire field arguments through the
@requiresexecution path (grpc datasource, federation visitor, compiler), doing it similar to how field resolvers already handle them.Tests
Three new integration + execution-plan test scenarios covering:
prefix: String!prefixes: [String!]!, maxResults: Int!google.protobuf.StringValue)prefix: StringChecklist