flowctl: fetch storage mappings via GraphQL instead of PostgREST - #3238
Draft
GregorShear wants to merge 4 commits into
Draft
flowctl: fetch storage mappings via GraphQL instead of PostgREST#3238GregorShear wants to merge 4 commits into
GregorShear wants to merge 4 commits into
Conversation
…pings` query
Adds an optional `filter: StorageMappingsFilter` argument to `storageMappings`,
following the composable-filter pattern used by `inviteLinks` (and the in-flight
`dataPlanes` filter). Its one field, `catalogPrefix: PrefixFilter`, narrows to a
catalog-prefix subtree — the same scoping the deprecated `by: { underPrefix }`
provides.
`catalogPrefix.startsWith` folds into the existing `under_prefix` code path, so
it flows through `authorized_prefixes` (bidirectional prefix overlap against the
caller's grants) and the query's subtree predicate unchanged. Predicates only
narrow; the caller's catalog-read scope is enforced regardless, so a filter can
never widen what a caller may see, and omitting it behaves exactly as before.
`by` and `filter` are mutually exclusive: they express the same subtree scoping
two ways, and rejecting both keeps the resolved scope unambiguous. `by` stays
for now — flowctl still uses it, and its `exactPrefixes` lookup has no `filter`
equivalent yet — but is re-deprecated to point callers at `filter`.
This is the schema half of migrating the UI's storage-mappings table off the
`by:` convention onto the filter-param pattern; the query shape is otherwise
unchanged, so existing consumers are unaffected.
…fixFilter` Extends `PrefixFilter` with `in: [String!]`, an exact-set match alongside the existing `startsWith` subtree match, and wires it into every consumer so the new field is never a silent no-op: - `storageMappings`: `filter.catalogPrefix.in` maps to the `exactPrefixes` path, the way `startsWith` maps to `underPrefix`. Within a filter the two are alternative query modes and are mutually exclusive (as `by`'s own `exactPrefixes`/`underPrefix` already are). - `inviteLinks` and `alertConfigs`: add an exact-equality WHERE clause, and narrow the authorized-prefix set by the `in` entries before the MAX_PREFIXES guard — the same narrowing `startsWith` already provides as a hint — so a caller with many grants isn't forced to page. Filtering stays narrow-only: predicates run against the caller's authorized prefixes, so `in` can never widen what a caller may see, and an entry the caller can't read (or that matches nothing) simply falls out. This makes `in` the single exact-match predicate on `PrefixFilter`, so a set of prefixes can be resolved in one request. It supersedes the separate single-value `is` field, which is dropped in the stacked effectiveAlertConfig change.
… queries Extending the shared `PrefixFilter` with `in` regenerates every graphql_client consumer's copy of the input, so flowctl's `alerts config` list/lookup queries must now name the field. Set `in_: None` — these paths filter by `startsWith` only, so behavior is unchanged; this just keeps the workspace compiling against the new schema.
Resolve storage mappings during `flowctl` source loading through the control-plane `storageMappings` GraphQL query rather than PostgREST.
The prior PostgREST path relied on row-level security, whose grant graph only walks downward: a user scoped to a sub-prefix (e.g. `acmeCo/team-a/`) could not read the tenant-root mapping at `acmeCo/`, so `flowctl discover` failed with an access error. The GraphQL resolver authorizes against the snapshot grant graph, which walks ancestors as well as descendants, so sub-prefix admins resolve tenant-root mappings correctly.
Requested prefixes are grouped by tenant and each group is fetched with the `filter: { catalogPrefix: { in } }` exact-set predicate (with pagination). Keeping each tenant in its own request means an unreadable foreign tenant — reachable through a cross-tenant reference — fails only its own request rather than hiding a readable tenant's mappings; such a group is treated as having no visible mappings and logged at debug level. Recovery mappings continue to be synthesized client-side with a zero control id.
GregorShear
force-pushed
the
greg/flowctl-gql-storage-mappings
branch
from
July 23, 2026 20:25
c02cdef to
31ad5e7
Compare
GregorShear
changed the base branch from
master
to
greg/gql-storage-mappings-filter
July 23, 2026 20:26
GregorShear
force-pushed
the
greg/gql-storage-mappings-filter
branch
3 times, most recently
from
July 24, 2026 20:38
572cb9c to
95c7343
Compare
GregorShear
marked this pull request as draft
July 30, 2026 16:50
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.
Summary
Resolves storage mappings during
flowctlsource loading through the control-planestorageMappingsGraphQL query instead of PostgREST.Stacked on #3242 — uses the new
filter: { catalogPrefix: { in } }predicate that PR adds. Review/merge #3242 first.Why
The PostgREST path relied on row-level security, whose grant graph only walks downward: a user scoped to a sub-prefix (e.g.
acmeCo/team-a/) could not read the tenant-root mapping atacmeCo/, soflowctl discoverfailed with an access error. The GraphQL resolver authorizes against the snapshot grant graph, which walks ancestors as well as descendants, so sub-prefix admins resolve tenant-root mappings correctly.How
filter: { catalogPrefix: { in: [...] } }(exact-set match) plus cursor pagination.Note on the filter
Originally written against
by: { exactPrefixes }. Rebased onto #3242 to use the going-forwardfilter: { catalogPrefix: { in } }predicate instead — the deprecatedbyargument stays available but this is the pattern the UI and flowctl now share.Testing
local_specsunit tests green (per-tenant grouping, URL-budget chunking).cargo check -p flowctlandcargo fmtclean.