Skip to content

fix(cli): read piped stdin for gen signing-key's overwrite prompt (Go parity)#5794

Open
Coly010 wants to merge 4 commits into
developfrom
columferry/cli-1865-gen-signing-key-read-piped-stdin-for-the-overwrite-prompt-in
Open

fix(cli): read piped stdin for gen signing-key's overwrite prompt (Go parity)#5794
Coly010 wants to merge 4 commits into
developfrom
columferry/cli-1865-gen-signing-key-read-piped-stdin-for-the-overwrite-prompt-in

Conversation

@Coly010

@Coly010 Coly010 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

Go's overwrite-confirmation prompt for gen signing-key reads piped stdin even in non-TTY mode (internal/utils/console.go's PromptYesNo/ReadLine, racing a 100ms timeout) and honors an explicit y/n answer. The TS port's signing-key.handler.ts had its own local confirmOverwrite that returned true unconditionally in non-TTY mode without reading stdin at all, so echo n | supabase gen signing-key silently overwrote the existing key file instead of canceling — a data-loss risk for scripted/CI usage.

Expected Behavior

  • Deletes the local confirmOverwrite and switches the call site to the shared legacyPromptYesNo helper (already used by seed buckets, config push, logout, storage rm, db pull), which already correctly implements Go's non-TTY read-with-timeout-and-parse behavior.
  • Swaps LegacyYesFlag for legacyResolveYes (matching those same five callers), so gen signing-key now also honors SUPABASE_YES and an explicit --yes=false, matching Go's viper.GetBool("YES").
  • Fails the overwrite closed (rather than silently defaulting to yes) when a real interactive TTY requests a non-text --output-format — this command has no structured json/stream-json payload (SIDE_EFFECTS.md), and the shared helper's own default-on-non-text short-circuit would otherwise silently overwrite irrecoverable key material with no prompt at all. A non-TTY caller (piped or not) is unaffected by this guard.

Fixes CLI-1865

… parity)

## Current Behavior

Go's overwrite-confirmation prompt for `gen signing-key` reads piped
stdin even in non-TTY mode (`internal/utils/console.go`'s
`PromptYesNo`/`ReadLine`, racing a 100ms timeout) and honors an
explicit y/n answer. The TS port's `signing-key.handler.ts` had its
own local `confirmOverwrite` that returned `true` unconditionally in
non-TTY mode without reading stdin at all, so `echo n | supabase gen
signing-key` silently overwrote the existing key file instead of
canceling — a data-loss risk for scripted/CI usage.

## Expected Behavior

- Deletes the local `confirmOverwrite` and switches the call site to
  the shared `legacyPromptYesNo` helper (already used by `seed
  buckets`, `config push`, `logout`, `storage rm`, `db pull`), which
  already correctly implements Go's non-TTY read-with-timeout-and-parse
  behavior.
- Swaps `LegacyYesFlag` for `legacyResolveYes` (matching those same
  five callers), so `gen signing-key` now also honors `SUPABASE_YES`
  and an explicit `--yes=false`, matching Go's `viper.GetBool("YES")`.
- Fails the overwrite closed (rather than silently defaulting to yes)
  when a real interactive TTY requests a non-text `--output-format` —
  this command has no structured json/stream-json payload
  (SIDE_EFFECTS.md), and the shared helper's own default-on-non-text
  short-circuit would otherwise silently overwrite irrecoverable key
  material with no prompt at all. A non-TTY caller (piped or not) is
  unaffected by this guard.

Fixes CLI-1865
@Coly010

Coly010 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5079b0c9b2

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

Comment thread apps/cli/src/legacy/commands/gen/signing-key/signing-key.handler.ts
Comment thread apps/cli/src/legacy/commands/gen/signing-key/signing-key.handler.ts
Comment thread apps/cli/src/legacy/commands/gen/signing-key/SIDE_EFFECTS.md
Coly010 added 3 commits July 6, 2026 15:41
…Go parity)

The runtime layer for `gen signing-key` never merged `stdinLayer`, unlike the
other five `legacyPromptYesNo` callers (config push, seed buckets, storage rm,
db pull, logout). A non-TTY overwrite prompt (e.g. `echo n | supabase gen
signing-key`) reads `Stdin` via `legacyPromptYesNo`, so the missing layer
crashed with "Service not found: supabase/runtime/Stdin" instead of honoring
or defaulting the prompt (review: #5794).
… json/stream-json mode (Go parity)

`legacyPromptYesNo` checks `output.format !== "text"` before it checks TTY, so
a non-TTY invocation under `--output-format json`/`stream-json` (e.g. `printf
'n\n' | supabase gen signing-key --output-format json`) hit that check first
and silently returned the default (true) without ever reading the piped
answer. Go's `console.PromptYesNo` (apps/cli-go/internal/utils/console.go:64-82)
has no concept of output format — it always reads piped stdin — so present a
text-shaped view of `output` to `legacyPromptYesNo` whenever we're not already
failing closed on a TTY, reaching its non-TTY read regardless of the declared
format (review: #5794).
…5794)

The Notes section already documented that the overwrite prompt honors
SUPABASE_YES, but the Environment Variables table still said there were none.
@Coly010

Coly010 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: fb95891bb3

ℹ️ 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 marked this pull request as ready for review July 6, 2026 15:42
@Coly010 Coly010 requested a review from a team as a code owner July 6, 2026 15:42
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

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

Preview package for commit fb95891.

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