Skip to content

fix(constellation): preserve remote defaults for omitted variables - #5436

Merged
dbarrosop merged 2 commits into
mainfrom
const-fix-reg
Nov 23, 2026
Merged

dbarrosop merged 2 commits into
mainfrom
const-fix-reg

Conversation

@dbarrosop

Copy link
Copy Markdown
Member

Goal

Restore Hasura-compatible effective defaults when clients omit GraphQL variables used by remote-schema arguments or input fields. The previous normalization substituted schema defaults whose intermediate representation could lose enum kinds, string quoting, and object/list contents. Preserve operation-variable defaults, explicit nulls, required-input validation, mutation-selector safety, SQL defaults, and cached-AST isolation.

Type: Bug fix

Changes

  • Default ownership — Omit arguments and input fields that refer to missing optional variables instead of substituting schema-default ASTs. The owning connector applies its schema defaults, including at non-null positions with defaults; non-null positions without defaults retain their variable references for validation.
  • Presence semantics — Keep operation-variable defaults and supplied values on their existing paths. Explicit nulls remain present, nullable list positions keep their indices, and mutation-selector omission remains an error rather than removing a restriction.
  • Regression coverage — Add 52 HTTP cases across introspected admin and permissioned-role remote schemas. Compare effective remote inputs with literal requests for enum, string, object, list, nested, non-null-with-default, null, and cached-variable cases. Extend SQL equivalence coverage for the geography use_spheroid default, retain upsert-default coverage, and update normalization expectations.
  • Execution contract — Document that normalization applies operation-variable defaults while schema defaults remain the field owner's responsibility.

Key files

  • services/constellation/connector/sql/graphql/queries/{input_variables.go,input_variables_test.go,variable_inputs_test.go} (+19/-6) — Shared normalization, omission expectations, and SQL-default equivalence.
  • services/constellation/controller/remote_schema_defaults_test.go (+394/-0) — Database-free HTTP regression matrix and validating remote fixture.
  • services/constellation/CLAUDE.md and services/constellation/docs/developers/query-execution.md (+2/-2 total) — Default-ownership contract.

Review comment: r4644276782
#5411 (comment)
Substituting lossy schema defaults corrupts forwarded remote enum, string,
object and list inputs when an optional variable is omitted. Omitting only
nullable positions would leave non-null inputs with defaults broken.

Resolution (direct):
NormalizeInputVariables now omits missing-variable arguments and input
fields instead of inlining schema defaults, leaving the owning connector
to apply them. Include non-null positions with defaults while retaining
operation-variable defaults, explicit null checks, required-input handling
and mutation-selector safeguards. This preserves Hasura-compatible coerced
values without reconstructing remote literals.

Add 52 HTTP remote-default regression cases across introspected admin and
permissioned SDL schemas, and SQL equivalence coverage for the geography
use_spheroid default. Existing omitted upsert update_columns coverage also
passes. Update normalization expectations and the documented contract.

Checks:
- `golines -w --base-formatter=gofumpt .` — exit 0.
- `golangci-lint run --fix ./...` — exit 0, no issues.
- `GOEXPERIMENT=jsonv2 go test -race -count=1 -run '^(TestRemoteSchemaOmittedVariableDefaults|TestNormalizeInputVariables|TestSelectorScope|TestFilterVariableInputs|TestJSONBVariableInputs|TestOrderByVariableInputs|TestVariableInputControls|TestOptionalVariableInputs|TestVariableInputsRejectInvalidValues|TestVariableInputsCachedDocument)$' ./services/constellation/controller ./services/constellation/connector/sql/graphql/queries` — exit 0.
- `GOEXPERIMENT=jsonv2 go test -race -count=1 ./services/constellation/connector/remoteschema ./services/constellation/connector/sql/graphql/queries/values` — exit 0.
- `make -C tools/vale lint-prose-changed` — exit 0, no errors; four
  pre-existing warnings outside the changed text.
- `nix build --impure --print-build-logs --out-link services/constellation/result-check --expr 'import ./.nhost-code/tmp/const-fix-reg-check.nix'` — exit 0.
  Run the full Constellation check derivation with only HASURA_URL and
  DATABASE_URL overridden for isolated ports 8443/5434, preserving the
  unrelated stack on 443/5432. All 49 tested packages, including the Hasura
  v2.50.3-ce integration comparisons, pass. Generation leaves all 2042
  checked files unchanged; vulnerability policy and lint pass.
Review comment: PR_const-fix-reg/RUN-17953993101725531490/WU-001 — .nhost-code/review/PR_const-fix-reg_COMMENT_001.md
Omitted variables at schema-defaulted positions inside mutation where inputs
were incorrectly rejected after remote defaults were left to the owning connector.
Resolution:
Schema-defaulted mutation selector arguments and input fields are now omitted for the owning connector to default at `services/constellation/connector/sql/graphql/queries/input_variables.go:279` and `:336`, rather than rejected or inlined. Non-defaulted restrictions still fail closed, and explicit-null/non-null validation is unchanged. Added regressions for delete/update/update-many/upsert SQL equivalence and admin/reader remote mutations, including sibling-restriction safety controls. The targeted race suite passes.

Checks:
- `nix develop .#constellation -c bash -c 'golines -w --base-formatter=gofumpt . && golangci-lint run --fix ./...'` — exit 0; repo-wide formatting and lint, 0 issues.
- `GOEXPERIMENT=jsonv2 go test -race -count=1 -run '^(TestNormalizeInputVariables|TestOptionalVariableInputs|TestVariableInputsRejectInvalidValues|TestFilterVariableInputs|TestVariableInputControls|TestVariableInputsCachedDocument|TestRemoteSchemaOmittedVariableDefaults)$' ./services/constellation/connector/sql/graphql/queries ./services/constellation/controller` — exit 0; default, selector-safety, null, and cache tests passed.
- `make -C tools/vale lint-prose-changed` — exit 0; no errors, four pre-existing warnings outside the changed text.
- `nix build --impure --print-build-logs --out-link services/constellation/result-check --expr 'import ./.nhost-code/tmp/const-fix-reg-check.nix'` — exit 0; full project check, 49 tested packages including the Hasura comparison suite and all 74 remote-default cases. The isolated check overrides only HASURA_URL and DATABASE_URL to use ports 8443/5434.
@dbarrosop
dbarrosop merged commit 19ba33c into main Nov 23, 2026
16 checks passed
@dbarrosop
dbarrosop deleted the const-fix-reg branch November 23, 2026 08:19
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