Skip to content

feat(cli): add --reveal flag to projects api-keys#5633

Open
Coly010 wants to merge 1 commit into
developfrom
fix/api-keys-new-keys
Open

feat(cli): add --reveal flag to projects api-keys#5633
Coly010 wants to merge 1 commit into
developfrom
fix/api-keys-new-keys

Conversation

@Coly010

@Coly010 Coly010 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What changed

Adds an opt-in --reveal boolean flag to supabase projects api-keys (native TS legacy shell).

When set, the command sends reveal=true to GET /v1/projects/{ref}/api-keys so the Management API returns the full secret keys (sb_secret_...) in api_key instead of redacting them to null. The redacted values then render as ****** across all output formats. With --reveal, the populated api_key flows through every format (text table, --output json/yaml/toml/env, and the TS --output-format json/stream-json envelope) — no formatter changes were needed since masking is purely null-based.

Why

Redaction is server-side: new secret keys come back null unless the request carries reveal=true, and the command never sent it. Users had no way to retrieve secret keys via the CLI, breaking CI/preview-environment flows that scrape keys (e.g. --output json/env) to populate service env vars. The same reveal=true mechanism was already used internally by other flows (link/bootstrap-adjacent) — it just wasn't exposed on this command.

Fixes #4775.

Reviewer context

  • Opt-in, default unchanged. The reveal query param is omitted entirely when the flag is absent, keeping the default request byte-identical to the Go CLI.
  • bootstrap is unaffected. It shares legacyGetProjectApiKeys but calls it without the flag and only consumes the never-redacted anon key, so it stays on the default path.
  • Scope: native TS only. The Go CLI (apps/cli-go) is intentionally not touched; the flag is recorded as a TS-only divergence in docs/go-cli-porting-status.md.
  • Telemetry: --reveal is a boolean, so its value is logged verbatim by the instrumentation (consistent with all other boolean flags); the secret key values are never logged, cached, or written to disk.

New secret API keys (`sb_secret_...`) are returned redacted by the
Management API unless the request carries `reveal=true`, so
`supabase projects api-keys` printed `******` for them with no override.
This breaks CI/preview-environment flows that scrape keys via
`--output json`/`env` to populate service env vars.

Add an opt-in `--reveal` boolean flag (native TS legacy shell only) that
threads `reveal=true` through the shared fetch helper. Default behavior is
unchanged and byte-identical to Go: the query param is omitted entirely
when the flag is absent, so `bootstrap` (which only consumes the
never-redacted anon key) stays on the default path. Masking is null-based,
so revealed keys flow through every output format with no formatter change.

Fixes #4775
@Coly010 Coly010 requested a review from a team as a code owner June 19, 2026 12:20
@Coly010 Coly010 self-assigned this Jun 19, 2026
@github-actions

Copy link
Copy Markdown

Supabase CLI preview

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

Preview package for commit f964fc6.

@Coly010 Coly010 enabled auto-merge June 19, 2026 13:00
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.

New api keys disabled a way to fetch them in CLI

1 participant