Skip to content

fix: handle default values for slicingArguments - #1499

Merged
ysmolski merged 7 commits into
masterfrom
yury/eng-9557-requireoneslicingargument-default-rejects-queries-that-rely
May 20, 2026
Merged

fix: handle default values for slicingArguments#1499
ysmolski merged 7 commits into
masterfrom
yury/eng-9557-requireoneslicingargument-default-rejects-queries-that-rely

Conversation

@ysmolski

Copy link
Copy Markdown
Contributor

This PR adds support of fields defaults specified in the schema for the field arguments/paths specified in slicingArgument. That includes nested InputObjects.

This PR adds support of fields defaults specified in the schema
for the field arguments/paths specified in slicingArgument.
That includes nested InputObjects.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9f31291d-b746-4807-834b-4dbf1dcb41c2

📥 Commits

Reviewing files that changed from the base of the PR and between 125e53e and fdc3c2c.

📒 Files selected for processing (1)
  • v2/pkg/engine/plan/cost.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • v2/pkg/engine/plan/cost.go

📝 Walkthrough

Walkthrough

This PR derives Int defaults for configured slicing-argument paths from the upstream SDL, exposes them on FieldListSize.SlicingArgumentDefaults, uses them when resolving slicing args for list-size multiplier calculation and RequireOneSlicingArgument validation, adds unit tests for default extraction, and wires default backfilling into data source configuration and execution tests.

Changes

Slicing argument defaults support

Layer / File(s) Summary
Core slicing argument resolution with defaults
v2/pkg/engine/plan/cost.go
FieldListSize gains SlicingArgumentDefaults map. New resolveSlicingArg helper reads slicing arguments from request variables/arguments and falls back to configured defaults when arguments are omitted. Both cost multiplier calculation and validateSliceArguments use the new resolver to treat defaulted arguments as provided.
SDL default extraction and validation
v2/pkg/engine/plan/cost_defaults.go
fillListSizeDefaults populates SlicingArgumentDefaults by resolving each configured slicing-argument dot-path to an effective leaf Int default from the schema. getEffectiveSlicingArgLeafDefault traverses field arguments and nested input-object definitions, applies shadowing semantics (outer non-Int defaults override inner ones), and returns the resolved Int leaf. findObjectFieldValue inspects object-literal AST defaults.
Wiring defaults into data source configuration
v2/pkg/engine/plan/datasource_configuration.go
NewDataSourceConfigurationWithName backfills SlicingArgumentDefaults for configured list sizes by fetching the upstream SDL and invoking fillListSizeDefaults when cost config and schema are available.
Unit tests for default extraction
v2/pkg/engine/plan/cost_defaults_test.go
Comprehensive test suite for fillListSizeDefaults covering flat and dotted-path slicing arguments, Int default enrichment from schema, shadowing behavior (explicit null suppresses inner defaults, non-Int defaults block resolution), and graceful handling of unresolvable paths, missing schema fields, nil schema/map entries, and empty slicing-argument lists.
Integration tests: cost estimation and validation with schema defaults
execution/engine/execution_engine_cost_test.go
Updated test schema naming (Search/Page replace SInput/PInput). Added tests verifying cost estimation falls back to flat defaults and nested object/dot-path defaults when operation inputs omit slicing arguments, and tests verifying RequireOneSlicingArgument treats defaulted slicing arguments as provided while treating explicit null and variable-null as absent.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • wundergraph/graphql-go-tools#1485: Both PRs modify the list-size slicing-argument resolution and validation logic in v2/pkg/engine/plan/cost.go; this PR extends resolution to consider SDL-declared defaults.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: handle default values for slicingArguments' directly and clearly describes the main change: adding support for schema-defined default values in slicing arguments.
Description check ✅ Passed The description accurately describes the changeset, explaining that the PR adds support for field defaults in slicingArgument configurations, including nested InputObjects.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yury/eng-9557-requireoneslicingargument-default-rejects-queries-that-rely

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@v2/pkg/engine/plan/cost.go`:
- Around line 116-123: The current logic around resolveSlicingArgIntValue treats
any non-success as "missing" and therefore applies SlicingArgumentDefaults even
when the user explicitly provided a null or non-int value; change
resolveSlicingArgIntValue (and its call sites in the dot-path branch inside the
slicing resolution code) to return a tri-state result (e.g., found | missing |
explicit_invalid) instead of a boolean, then update the dot-path handling (the
if strings.Contains(slicingArg, ".") block) so that defaultValue is applied only
when the result is missing, not when explicit_invalid; update any downstream
checks that rely on presence (e.g., RequireOneSlicingArgument logic) to treat
explicit_invalid as provided-but-unusable rather than omitted so defaults and
multiplier calculations only use SlicingArgumentDefaults for truly missing
paths.
🪄 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: 7fbfa39e-b446-422e-8022-6abb05fae0c7

📥 Commits

Reviewing files that changed from the base of the PR and between b08f86e and d11a77d.

📒 Files selected for processing (5)
  • execution/engine/execution_engine_cost_test.go
  • v2/pkg/engine/plan/cost.go
  • v2/pkg/engine/plan/cost_defaults.go
  • v2/pkg/engine/plan/cost_defaults_test.go
  • v2/pkg/engine/plan/datasource_configuration.go

Comment thread v2/pkg/engine/plan/cost.go

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@v2/pkg/engine/plan/cost.go`:
- Around line 129-142: The current branch in cost.go that handles flat slicing
args (the block around args[slicingArg] and the hasVariable check) returns false
when the variable is present but set to nil, preventing falling back to
SlicingArgumentDefaults; update the logic in that branch so that if
arg.hasVariable is true and vars != nil but vars.Get(arg.varName) is nil (or not
a number), it should fall through to use the defaultValue when hasDefault is
true (instead of immediately returning 0,false). Concretely: in the args lookup
path for slicingArg in the function containing this snippet, only return
vars.GetInt(...) when the variable exists and is a number; otherwise, if
hasDefault is true return defaultValue,true; keep the final return 0,false
otherwise. Also add a regression test for the case items(first: $limit) with
empty variables and an SDL default to ensure SlicingArgumentDefaults and
RequireOneSlicingArgument behave correctly.
🪄 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: c00d7d20-5cde-43b6-97f7-a8d85547d192

📥 Commits

Reviewing files that changed from the base of the PR and between d11a77d and 7f161e0.

📒 Files selected for processing (3)
  • execution/engine/execution_engine_cost_test.go
  • v2/pkg/engine/plan/cost.go
  • v2/pkg/engine/plan/cost_defaults_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • v2/pkg/engine/plan/cost_defaults_test.go

Comment thread v2/pkg/engine/plan/cost.go

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@v2/pkg/engine/plan/cost.go`:
- Around line 137-146: The current branch inside the argument resolution block
treats a nil vars pointer as "no default" and falls through; update the logic in
the function handling slicing args so that when arg.hasVariable is true and vars
== nil it is treated as the variable being omitted (so if hasDefault is true
return defaultValue, true). Concretely, in the block that references
arg.hasVariable, vars, arg.varName, hasDefault and defaultValue, restructure the
checks to first test if vars == nil and return the default if available,
otherwise keep the existing path that calls vars.Get(arg.varName) and
vars.GetInt(arg.varName); this ensures behavior for omitted variables matches
SlicingArgumentDefaults and RequireOneSlicingArgument.
🪄 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: 6bd180b7-b727-44b9-bda0-4ef0f5f5bc02

📥 Commits

Reviewing files that changed from the base of the PR and between a60ec03 and 890c2a5.

📒 Files selected for processing (2)
  • execution/engine/execution_engine_cost_test.go
  • v2/pkg/engine/plan/cost.go

Comment thread v2/pkg/engine/plan/cost.go Outdated
@ysmolski
ysmolski merged commit f3afd10 into master May 20, 2026
10 checks passed
@ysmolski
ysmolski deleted the yury/eng-9557-requireoneslicingargument-default-rejects-queries-that-rely branch May 20, 2026 14:08
ysmolski pushed a commit that referenced this pull request May 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.3.1](v2.3.0...v2.3.1)
(2026-05-20)


### Bug Fixes

* handle default values for slicingArguments
([#1499](#1499))
([f3afd10](f3afd10))
* multiply with 0 for empty lists in actual costs
([#1502](#1502))
([1cb6bde](1cb6bde))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
ysmolski pushed a commit that referenced this pull request May 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.15.1](execution/v1.15.0...execution/v1.15.1)
(2026-05-21)


### Bug Fixes

* handle default values for slicingArguments
([#1499](#1499))
([f3afd10](f3afd10))
* multiply with 0 for empty lists in actual costs
([#1502](#1502))
([1cb6bde](1cb6bde))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants