fix(cli): comma-split network-bans and network-restrictions slice flags like pflag (CLI-1983) - #5975
Draft
Coly010 wants to merge 1 commit into
Conversation
…gs like pflag (CLI-1983)
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
What changed
Go declares both
--db-unban-ip(network-bans remove,cmd/bans.go:48) and--db-allow-cidr(network-restrictions update,cmd/restrictions.go:40) with pflag'sStringSliceVar, which CSV-splits every occurrence (--db-unban-ip=1.2.3.4,5.6.7.8→ two IPs) and appends across repeated flags. The TS legacy ports used plainFlag.string(...).pipe(Flag.atLeast(0))with no splitting, so a comma-separated value stayed one token and failed validation (invalid IP address: 1.2.3.4,5.6.7.8/failed to parse IP: 1.2.3.0/24,5.6.7.0/24) where the Go CLI accepts both values.Both flags now route through the existing parity-reviewed
legacyParseStringSliceFlaghelper (the sameencoding/csv-faithful pipeline already used bysso --domains,postgres-config --config,start, andstatus), using the establishedFlag.mapTryCatchpattern. This restores Go-identical semantics: comma-split per occurrence, append across repeats, CSV quoting for embedded commas, no trimming, and parse-time rejection of malformed CSV (which, as in Go, precedes the--experimentalgate and handler validation).Scope check: these are the only two
StringSliceVarflags in either command family (--bypass-cidr-checksand--appendare booleans,--project-refis a plain string), so no sibling flags needed the same fix. Flag names, defaults, and help text are unchanged, sodocs/go-cli-porting-status.mdneeds no update.New coverage: flag-parse unit tests per command (comma split, quoted embedded comma, unset default, malformed-CSV rejection) plus integration scenarios that run the real flag pipeline into the handler and assert the resulting request bodies (comma form, repeated append, mixed, single-value regression, and an invalid post-split element failing before any API call). The new tests fail without the fix.
Review notes (deliberately left open)
invalid argument "..." for "--db-unban-ip" flag: parse error ...wrapper) is asserted nowhere in the repo — a pre-existing gap shared with the sso/postgres-config slice-flag tests; this PR matches the existing pattern rather than solving it unilaterally.-o badplus malformed CSV in one invocation), TS surfaces the CSV parse error while Go's winner depends on argv order; both exit non-zero. No action taken.Fixes CLI-1983
https://linear.app/supabase/issue/CLI-1983/db-unban-ip-and-db-allow-cidr-dont-comma-split-like-gos-stringslicevar