fix(account): clear error for password prompts with no TTY - #390
Merged
Conversation
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).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
Member
Author
|
/run-e2e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
genlayer account export --password <pw>(without--source-password) — and any password prompt run non-interactively (piped stdin, CI, automation) — died with: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
promptPasswordnow callsassertInteractive()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.exportandimportpass contextual hints (--source-password/--password).Scope kept tight to the reported password path:
confirmPromptis intentionally untouched (its callers gate on their own--yes/--overwriteflags).Test
tests/libs/baseAction.test.ts: asserts the actionable throw (with and without a flag hint) and that inquirer is never invoked.Depends-On: genlayerlabs/genlayer-consensus#1179