flowctl: normalize --prefix trailing slash to avoid misleading PermissionDenied#3075
Open
GregorShear wants to merge 1 commit into
Open
flowctl: normalize --prefix trailing slash to avoid misleading PermissionDenied#3075GregorShear wants to merge 1 commit into
GregorShear wants to merge 1 commit into
Conversation
…sionDenied Passing `--prefix <tenant>` without a trailing slash (e.g. `--prefix AcmeCo`) sent the value verbatim to `models::Prefix::new`. Estuary prefixes must end in `/`, so the control plane treated the value as an unrecognized catalog name and returned a misleading `PermissionDenied` error even for fully-authorized users. Normalize the prefix in `to_vars`, the single point through which `catalog list`, `catalog pull-specs`, and `catalog delete` all route their `--prefix` values. A missing trailing slash is appended; an empty prefix is preserved, since it is a valid "everything" selector and a bare `/` would be rejected. Closes #2834
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.
Problem
flowctl catalog pull-specs --prefix AcmeCo(no trailing slash) returns a misleading error even for fully-authorized users:The value is passed verbatim to
models::Prefix::new. Estuary prefixes must end in/, so the control plane treatsAcmeCoas an unrecognized catalog name rather than a prefix and rejects it.Fix
Auto-normalize the prefix by appending a trailing
/when it's missing. The fix lives into_vars— the single point through which everyNameSelector-based command routes its--prefixvalues:catalog listcatalog pull-specscatalog deleteAn empty prefix is deliberately left untouched:
""is a valid selector meaning "everything the user can access", whereas"/"is invalid, so blindly appending would introduce a new bug.Testing
test_normalize_prefixcovers the missing-slash case, multi-segment prefixes, already-normalized input, and the empty edge case.cargo test -p flowctl normalize_prefixpasses.Out of scope
flowctl alerts subscriptionsandflowctl rawaccept their own--prefixargs that don't go throughNameSelector, so they retain the same foot-gun. The issue scoped the fix toNameSelector; happy to fold those in as a follow-up if desired.Closes #2834