Skip to content

fix(account): clear error for password prompts with no TTY - #390

Merged
MuncleUscles merged 2 commits into
v0.40-devfrom
fix/noninteractive-password-error
Jul 10, 2026
Merged

fix(account): clear error for password prompts with no TTY#390
MuncleUscles merged 2 commits into
v0.40-devfrom
fix/noninteractive-password-error

Conversation

@MuncleUscles

@MuncleUscles MuncleUscles commented Jul 10, 2026

Copy link
Copy Markdown
Member

What

genlayer account export --password <pw> (without --source-password) — and any password prompt run non-interactively (piped stdin, CI, automation) — died with:

ExitPromptError: User force closed the prompt with 0 null

That's inquirer's message for a force-closed prompt: it reads exactly like the user hit Ctrl-C, when in fact a required flag is simply missing. Reported from field automation use.

Fix

promptPassword now calls assertInteractive() first: when stdin is not a TTY it throws an actionable error naming the flag(s) that make the command non-interactive, instead of letting inquirer force-close. export and import pass contextual hints (--source-password / --password).

No interactive terminal available for a prompt. Pass --source-password to unlock the account non-interactively.

Scope kept tight to the reported password path: confirmPrompt is intentionally untouched (its callers gate on their own --yes/--overwrite flags).

Test

  • New non-TTY cases in tests/libs/baseAction.test.ts: asserts the actionable throw (with and without a flag hint) and that inquirer is never invoked.
  • Existing prompt tests now simulate a TTY (vitest stdin is not one). Full suite green: 773/773.

Depends-On: genlayerlabs/genlayer-consensus#1179

Running e.g. `genlayer account export --password <pw>` without --source-password
in a non-interactive context (piped stdin, CI, automation) died with
`ExitPromptError: User force closed the prompt` — inquirer's message for a
force-closed prompt, which reads exactly like the user hit Ctrl-C when in fact
a required flag is missing.

Guard promptPassword with assertInteractive(): when stdin is not a TTY, throw an
actionable error naming the flag(s) that make the command non-interactive
(--source-password / --password) instead of letting inquirer force-close. export
and import pass contextual hints. confirmPrompt is intentionally left alone
(its callers gate on their own --yes/--overwrite flags).

Adds non-TTY coverage in baseAction.test.ts; existing prompt tests simulate a
TTY (vitest stdin is not one).
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4ce5b61e-adb2-4477-a3f5-ad4a5076146e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/noninteractive-password-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MuncleUscles

Copy link
Copy Markdown
Member Author

/run-e2e

The first cut guarded promptPassword with !process.stdin.isTTY, which was too
blunt: it rejected PIPED stdin outright. But piped stdin is exactly how the e2e
harness (and real automation) supply the keystore password — so `genlayer
deploy` and every keystore-unlock path started failing with 'Maximum password
attempts exceeded' in CI (isTTY is false for a pipe, so the guard threw before
inquirer could read the piped password).

Instead, let inquirer run and catch its ExitPromptError ('User force closed the
prompt') — which only fires on an ACTUAL force-close (no TTY AND no piped
input). Rewrite that into the actionable, flag-naming message. Piped stdin now
reaches inquirer normally; the clear error still appears when there is genuinely
no input.

Verified against a keystore: piped source-password exports OK; empty stdin
yields 'No interactive terminal available for a password prompt. Pass
--source-password ...'. 774/774 unit tests.
@MuncleUscles

Copy link
Copy Markdown
Member Author

/run-e2e

@MuncleUscles
MuncleUscles merged commit 0ce6b1b into v0.40-dev Jul 10, 2026
9 of 10 checks passed
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