Skip to content

fix(cli): exempt global choice flags from telemetry redaction (Go isEnumFlag parity)#5855

Merged
Coly010 merged 2 commits into
developfrom
columferry/cli-1904-telemetry-global-choice-flags-output-dns-resolver-agent
Jul 10, 2026
Merged

fix(cli): exempt global choice flags from telemetry redaction (Go isEnumFlag parity)#5855
Coly010 merged 2 commits into
developfrom
columferry/cli-1904-telemetry-global-choice-flags-output-dns-resolver-agent

Conversation

@Coly010

@Coly010 Coly010 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What changed

Go's isEnumFlag (apps/cli-go/cmd/root_analytics.go:110-116) unconditionally reports the value of any *utils.EnumFlag-backed pflag verbatim in cli_command_executed telemetry — no per-flag annotation needed. --output, --dns-resolver, and --agent are all registered as *utils.EnumFlag on rootCmd.PersistentFlags() (cmd/root.go:330,331,333), so Go always sends their real value.

The TS port's withLegacyCommandInstrumentation already auto-detects Flag.choice flags declared in a command's own config (CLI-1866), and already resolves global/persistent flag values as a fallback when a command doesn't declare that CLI name locally (CLI-1896). But CLI-1896 deliberately scoped out the 3 global choice flags — nothing taught the global-fallback path that a resolved value might itself be a safe enum, so --output/--dns-resolver/--agent always fell through to "<redacted>".

This adds GLOBAL_CHOICE_FLAG_NAMES (legacy-command-instrumentation.ts), derived from LEGACY_GLOBAL_FLAGS by reusing the existing getChoiceFlagNames helper (so the choice-detection predicate has exactly one home), and consults it only on the global-fallback path — i.e. only when the invoking command's own flags record doesn't already declare that CLI name. A command that registers its own differently-typed local flag under the same CLI name (db diff's local string output: Flag.string("output"), cmd/db.go:622) still shadows the global and stays redacted, matching Go's isEnumFlag type-asserting that command's own non-enum flag object instead of root's persistent EnumFlag. Verified this is the real wiring, not a hypothetical: db diff passes output in its own flags record with no matching config entry, so isFromHandler is structurally true for it and the new global set is never consulted.

Also verified Go's separate output_format telemetry property (PropOutputFormat) is independent of the generic flags.output entry — both already fire in Go too, so no double-counting concern from un-redacting flags.output.

Fixes CLI-1904.

Why

Found during CLI-1866's review as a pre-existing gap in the same problem class, tracked separately since it was out of scope for that PR's diff, then explicitly deferred again by CLI-1896 ("the 3 global choice flags ... remain redacted — that gap is the already-tracked CLI-1904, not this ticket").

Reviewer-relevant context

  • All 4 review-changes agents (architect, engineer, security, DX) reviewed this diff and approved with no blocking findings. Two converging nits were fixed in a follow-up commit: deduped the choice-detection predicate (GLOBAL_CHOICE_FLAG_NAMES now derives from getChoiceFlagNames instead of re-implementing it) and clarified the two AGENTS.md telemetry bullets.
  • One deliberately-deferred judgement call from engineer-reviewer: no command's own *.integration.test.ts today exercises withLegacyCommandInstrumentation's PostHog-capture behavior for any flag (that coverage is entirely the job of legacy-command-instrumentation.unit.test.ts's own scenario suite) — this is a pre-existing, repo-wide pattern, not something this PR narrows or regresses. Adding integration-tier telemetry assertions to db diff/db query specifically would set a new cross-cutting test precedent well beyond this fix's scope, so left as a possible future hardening rather than folded in here.

Coly010 added 2 commits July 10, 2026 10:12
…numFlag parity)

--output, --dns-resolver, and --agent are registered as *utils.EnumFlag on
Go's rootCmd.PersistentFlags() (cmd/root.go:330-333), so Go's isEnumFlag
(cmd/root_analytics.go:110-116) always reports their changed value verbatim
in cli_command_executed telemetry. The TS port's global-flag fallback in
buildFlagsMap only ever fell through to REDACTED_VALUE for these three,
since CLI-1866's config-based choice detection only covers a command's own
locally-declared flags, not the shared global registry.

Add GLOBAL_CHOICE_FLAG_NAMES, derived from LEGACY_GLOBAL_FLAGS the same way
GLOBAL_SHORT_ALIASES already is, and consult it only on the global-fallback
path (a changed flag not present in the invoking command's own `flags`
record). A command that registers its own differently-typed local flag under
the same CLI name (e.g. db diff's local string --output) still shadows the
global and stays redacted, matching Go's isEnumFlag type-asserting that
command's own non-enum flag object instead of root's persistent EnumFlag.

CLI-1904
Review follow-up on the CLI-1904 fix (all 4 review-changes agents approved,
no blocking findings):

- GLOBAL_CHOICE_FLAG_NAMES now derives from the existing getChoiceFlagNames
  helper instead of re-implementing its unwrap-and-classify predicate, so the
  two can never silently drift apart (architect-reviewer + engineer-reviewer).
- Reworked the two AGENTS.md telemetry bullets into shorter sentences/a list
  and made the "config cannot cover global flags" reasoning explicit inline
  (supabase-dx-reviewer).
@Coly010

Coly010 commented Jul 10, 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: d70116e5a7

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

@Coly010 Coly010 self-assigned this Jul 10, 2026
@Coly010 Coly010 marked this pull request as ready for review July 10, 2026 09:55
@Coly010 Coly010 requested a review from a team as a code owner July 10, 2026 09:55
@github-actions

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@d70116e5a76861bd1b760c2045b74680746663fa

Preview package for commit d70116e.

@Coly010 Coly010 added this pull request to the merge queue Jul 10, 2026
Merged via the queue into develop with commit 7c047c5 Jul 10, 2026
29 checks passed
@Coly010 Coly010 deleted the columferry/cli-1904-telemetry-global-choice-flags-output-dns-resolver-agent branch July 10, 2026 12:50
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.

2 participants