Repository navigation
fix(constellation): honor query and subscription root permissions - #5455
Merged
Merged
Conversation
Honor Hasura query and subscription root allowlists independently, including the distinction between omitted and empty lists in persisted metadata. Prune unreachable schema types after composing relationships so the support-alias public schema matches Hasura without disabling nested selections. Verified with Constellation package tests on PostgreSQL 18.3, repository Go lint, and schema diffs against both the console metadata files and a live Hasura metadata export.
Review comment: PR_const-fix-root/RUN-14822775318558038815/WU-001 — .nhost-code/review/PR_const-fix-root_COMMENT_001.md
Hiding every query root also disabled introspection, unlike Hasura.
Resolution:
ADDRESSED — Schema composition adds `no_queries_available: String!` only when the role has no real query fields. The controller resolves it locally for that role without shadowing a same-named connector field in another role. Tests cover mutation-only and stream-only roles.
Review comment: PR_const-fix-root/RUN-14822775318558038815/WU-002 — .nhost-code/review/PR_const-fix-root_COMMENT_002.md
Source customization had no regression coverage for preserving RestrictedReadRoots.
Resolution:
ADDRESSED — The SQL schema regression applies a source namespace and type prefix, then checks that pruning removes unused types but keeps types reachable through nested selections and the allowed by-primary-key root.
Review comment: PR_const-fix-root/RUN-14822775318558038815/WU-003 — .nhost-code/review/PR_const-fix-root_COMMENT_003.md
Nothing tested that composition retains cross-source relationship types and merges restriction flags with OR semantics.
Resolution:
ADDRESSED — The composer regression combines two SQL-generated source schemas, verifies the relationship and its aggregate after pruning, and checks that an unused type from the later, unrestricted source is removed. Both ordering and OR regressions fail the test under Go overlays.
Review comment: PR_const-fix-root/RUN-14822775318558038815/WU-004 — .nhost-code/review/PR_const-fix-root_COMMENT_004.md
The remote-schema guide still pointed to the deleted connector pruner.
Resolution:
ADDRESSED — The developer guide points to `graph/prune.go` and `connector/remoteschema/builtin_types.go` and explains why composed-schema pruning follows relationship injection.
Review comment: PR_const-fix-root/RUN-14822775318558038815/WU-005 — .nhost-code/review/PR_const-fix-root_COMMENT_005.md
The permission summary implied the lists also gated independently permitted tracked function roots.
Resolution:
ADDRESSED — The permission guides limit the lists to generated table roots and explain that tracked functions keep their own grants while applying the table's select filter and column permissions.
Review comment: PR_const-fix-root/RUN-14822775318558038815/WU-006 — .nhost-code/review/PR_const-fix-root_COMMENT_006.md
Invalid operation names and coerced non-string entries silently hid roots instead of producing a diagnostic.
Resolution:
ADDRESSED — Hasura YAML and JSON and native TOML share the operation-name check. Invalid lists fail on load; omitted or null lists still keep defaults and explicit empty lists still suppress roots. Metadata tests cover inline and included YAML, JSON, and TOML.
Checks:
- `golines -w --base-formatter=gofumpt .` — 0, formatted Go files.
- `golangci-lint run --fix ./...` — 0, no lint findings.
- `go test ./services/constellation/connector/{composer,customization,schemamerge,relationships,remoteschema}/... ./services/constellation/metadata ./services/constellation/metadata/internal/hasura ./services/constellation/graph/... ./services/constellation/controller/introspection` — 0, tests passed.
- `go test ./services/constellation/connector/sql/graphql/schema ./services/constellation/controller -run 'Test(GenerateForRole_.*RootFieldPermissions|Resolve_(EmptyQueryRoot|NoFallback|Introspection)|GroupFieldsByConnector)' -count=1` — 0, focused tests passed.
- `python3 .nhost-code/tmp/check-root-allowlist-mutations.py` — 0, all three overlay regressions failed as intended.
- `make -C tools/vale lint-prose-changed` — 0, only four warnings on unchanged lines.
- `git diff --cached --check` — 0, no whitespace errors.
Final validation: pending
Review comment: PR_const-fix-root/RUN-18222056244990112697/WU-001 — .nhost-code/review/PR_const-fix-root_COMMENT_001.md
The new allowlist decoder and validator had no package-level tests.
Resolution:
Added black-box Decode and Validate tests in services/constellation/internal/selectroots/selectroots_test.go. They cover null and empty lists, both operation kinds, bad shapes, indexed errors, and the supported operation names.
Review comment: PR_const-fix-root/RUN-18222056244990112697/WU-002 — .nhost-code/review/PR_const-fix-root_COMMENT_002.md
An explicit by-PK or aggregate root without its prerequisites left the remaining select permission active unlike Hasura.
Resolution:
SQL reconciliation drops the entire select permission and records a select_permission inconsistency after expanding and filtering column grants. Unit tests cover both root lists and valid grants; the SQLite HTTP regression verifies that neither root nor nested reads remain available to the affected role. The user guides describe the rule.
Review comment: PR_const-fix-root/RUN-18222056244990112697/WU-006 — .nhost-code/review/PR_const-fix-root_COMMENT_006.md
The metadata validator and schema generator kept independent copies of operation names, and no positive schema case selected the collection root explicitly.
Resolution:
Metadata loading, SQL reconciliation, and schema generation use the same operation constants in services/constellation/internal/selectroots. A parsed [select] allowlist now has a positive query and subscription schema case that rejects an operation-name drift mutation.
Checks:
- `golines -w --base-formatter=gofumpt .` and `golangci-lint run --fix ./...` — exit 0.
- `go test ./services/constellation/internal/selectroots -count=1 -cover` — exit 0, 100% statement coverage.
- `go test ./services/constellation/{metadata,metadata/internal/hasura} -count=1` — exit 0 (part of the focused package run).
- `go test ./services/constellation/connector/sql/graphql/schema ./services/constellation/connector/sql ./services/constellation/controller -run 'Test(GenerateForRole_.*RootFieldPermissions|ReconcileMetadata|SelectRootPermissionInconsistencyHTTP|Resolve_EmptyQueryRoot)' -count=1` — exit 0.
- `python3 .nhost-code/tmp/check-selectroots-review-overlays.py` — exit 0; the [select] schema case detects a name mismatch.
- `make -C tools/vale lint-prose-changed` — exit 0; unchanged lines only have warnings.
Final validation: pending
Review comment: PR_const-fix-root/RUN-18222056244990112697/WU-003 — .nhost-code/review/PR_const-fix-root_COMMENT_003.md
BuildValidatedSchema's godoc did not name the condition that activates pruning.
Resolution:
The BuildValidatedSchema godoc now names RestrictedReadRoots, documents reachability from operation roots and directive arguments on a shallow copy, and distinguishes validation from composition's empty-query fallback.
Review comment: PR_const-fix-root/RUN-18222056244990112697/WU-004 — .nhost-code/review/PR_const-fix-root_COMMENT_004.md
The query-execution guide referenced a removed introspection shortcut and omitted local fallback routing.
Resolution:
The query-execution guide now explains how groupFieldsByConnector separates local selections, why no_queries_available is gated by role and operation, and how executeWithLocalFields resolves aliases alongside meta-fields and merges mixed results.
Checks:
- `golines -w --base-formatter=gofumpt .` and `golangci-lint run --fix ./...` — exit 0.
- `go test ./services/constellation/{connector/composer,connector/schemamerge} -count=1` — exit 0 (part of the focused package run).
- `make -C tools/vale lint-prose-changed` — exit 0; unchanged lines only have warnings.
Final validation: pending
Review comment: PR_const-fix-root/RUN-18222056244990112697/WU-005 — .nhost-code/review/PR_const-fix-root_COMMENT_005.md No direct graph tests distinguished implicit default operation names from explicitly declared roots. Resolution: Added TestPruneUnreachableTypes_RootSelection. It retains the implicit default roots when no roots are declared and prunes undeclared roots and their exclusive dependencies when a custom query root is declared. Both overlay mutations were rejected. Checks: - `golines -w --base-formatter=gofumpt .` and `golangci-lint run --fix ./...` — exit 0. - `go test ./services/constellation/graph -count=1` — exit 0 (part of the focused package run). - `python3 .nhost-code/tmp/check-selectroots-review-overlays.py` — exit 0; both pruning mutations fail the new direct test. Final validation: pending
Review comment: PR_const-fix-root/RUN-13703028066866928523/WU-001 — .nhost-code/review/PR_const-fix-root_COMMENT_001.md Dropping an invalid select permission before indexing computed grants could turn a dependent stale predicate into a source-wide build error. Resolution: Select-root checks now run after computed-field reconciliation in connector/sql/reconcile.go. The regression verifies that both invalid permissions are recorded and removed, the healthy grant survives, and PostgreSQL root construction succeeds. Checks: - `go test ./services/constellation/connector/sql -run '^TestReconcileMetadata_SelectRootAllowlistsPreserveComputedGrantIndex$' -count=1` — reproduced the root-build failure before the fix. - `go test ./services/constellation/connector/sql -run '^TestReconcileMetadata' -count=1` — exit 0 after the fix. - `golines -w --base-formatter=gofumpt .` and `golangci-lint run --fix ./...` — exit 0. - `CGO_ENABLED=1 go test ./services/constellation/connector/sql ./services/constellation/controller ./services/constellation/connector/sql/graphql/schema -run 'Test(ReconcileMetadata|SelectRootPermissionsHTTP|Resolve_EmptyQueryRoot|GenerateForRole_.*RootFieldPermissions)' -count=1` — exit 0. Final validation: pending
Review comment: PR_const-fix-root/RUN-13703028066866928523/WU-003 — .nhost-code/review/PR_const-fix-root_COMMENT_003.md Existing controller tests did not execute valid by-primary-key-only roots or nested reads into a table with all roots hidden. Resolution: TestSelectRootPermissionsHTTP uses SQLite to execute the custom by-primary-key root with a row filter, reject the hidden collection root, confirm there is no subscription root, and read permitted nested rows with both target allowlists empty. Checks: - `golines -w --base-formatter=gofumpt .` and `golangci-lint run --fix ./...` — exit 0. - `CGO_ENABLED=1 go test ./services/constellation/connector/sql ./services/constellation/controller ./services/constellation/connector/sql/graphql/schema -run 'Test(ReconcileMetadata|SelectRootPermissionsHTTP|Resolve_EmptyQueryRoot|GenerateForRole_.*RootFieldPermissions)' -count=1` — exit 0. Final validation: pending
Review comment: PR_const-fix-root/RUN-13703028066866928523/WU-004 — .nhost-code/review/PR_const-fix-root_COMMENT_004.md The developer guides' snapshots omitted per-role fallback routing state. Resolution: The architecture and query-execution guides now list emptyQueryRoots and describe its role in resolving no_queries_available locally. Review comment: PR_const-fix-root/RUN-13703028066866928523/WU-005 — .nhost-code/review/PR_const-fix-root_COMMENT_005.md The inconsistency guide named the validation-only entry point rather than the composer call that can record a role inconsistency. Resolution: The inconsistency guide now names schemamerge.BuildComposedSchema as the merged role-schema validation step. Checks: - `make -C tools/vale lint-prose-changed` — exit 0, no errors on changed prose. - Verified the documented symbols against controller state and the composer call site. Final validation: pending
dbarrosop
enabled auto-merge (squash)
November 26, 2026 13:15
albertomolinafelipe
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Make Constellation honor Hasura's per-table query and subscription root allowlists. The
support-aliaspublic role should retainfile(id:)without gaining a files collection or file subscriptions. Root restrictions must preserve permitted nested reads and schema introspection.Type: Bug fix
Changes
allow_aggregations. It records invalid grants as select-permission inconsistencies and drops the entire grant, without removing other permissions.no_queries_available. The controller resolves it locally only for that role's query operation, leaving same-named connector fields elsewhere untouched.Key files
services/constellation/{metadata,internal/selectroots}/(+166/-16 production) — metadata decoding and operation validation.services/constellation/connector/sql/(+126/-36 production) — permission reconciliation and SQL root generation.services/constellation/{connector/{composer,customization,memconnector,remoteschema,schemamerge},graph}/(+285/-143 production) — composition, graph pruning, and fallback insertion.services/constellation/controller/(+41/-36 production) — per-role fallback routing.services/constellation/tests (+1744/-250) and guides (+30/-11) — regression checks and behavior documentation.