Skip to content

fix(cli): comma-split network-bans and network-restrictions slice flags like pflag (CLI-1983) - #5975

Draft
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1983--db-unban-ip-and-db-allow-cidr-dont-comma-split-like-gos
Draft

fix(cli): comma-split network-bans and network-restrictions slice flags like pflag (CLI-1983)#5975
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1983--db-unban-ip-and-db-allow-cidr-dont-comma-split-like-gos

Conversation

@Coly010

@Coly010 Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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's StringSliceVar, 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 plain Flag.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 legacyParseStringSliceFlag helper (the same encoding/csv-faithful pipeline already used by sso --domains, postgres-config --config, start, and status), using the established Flag.mapTryCatch pattern. 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 --experimental gate and handler validation).

Scope check: these are the only two StringSliceVar flags in either command family (--bypass-cidr-checks and --append are booleans, --project-ref is a plain string), so no sibling flags needed the same fix. Flag names, defaults, and help text are unchanged, so docs/go-cli-porting-status.md needs 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)

  • The rendered flag-error wording for malformed CSV (Go's 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.
  • In the pathological double-error case (-o bad plus 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

@Coly010

Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 09ab038073

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

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.

1 participant