Repository navigation
fix(auth): fail the login prompt when stdin ends without an answer - #338
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/utils/auth.ts">
<violation number="1" location="src/utils/auth.ts:46">
P2: The EOF fallback resolves raw keystrokes in a TTY. If a user erases typed text (backspace or Ctrl+U) and then presses Ctrl+D, `unterminated` still holds the erased bytes, and `trim()` does not remove them. Limit the raw-stdin fallback to non-TTY input so an interactive EOF rejects instead.</violation>
</file>
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Makes the login prompts reject when stdin ends without an answer, so firecrawl login/init no longer exit 0 mid-prompt; tests cover the new rejection and piped-key behavior. The fix is focused and pins the corrected behavior.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Makes the login prompts reject when stdin ends without an answer, so firecrawl login/init no longer exit 0 mid-prompt; tests pin the new rejection and piped-input behavior. Focused, tested bug fix with no new exposure.
View guided diff | Turn on auto-fix | Re-trigger cubic

The login prompts read stdin with
readline.question. When stdin ends before an answer (CI, coding agents, scripts,</dev/null), the callback never fires, the pending promise empties the event loop, and Node exits 0 right after printingEnter choice [1/2]:.That hits two common paths:
firecrawl loginwithout a terminal prints the menu and exits 0 with nothing saved.firecrawl init --all(or-y) without--browserand without a key stops at step 1 and exits 0, so the skills step never runs and the caller sees success.promptInputinsrc/utils/auth.tsnow rejects when readline closes before an answer, with:Piped answers still work. Without a terminal, one line reader serves every prompt, so a pipe can answer several prompts in a row (
printf '2\nfc-...\n' | firecrawl login), and a last answer without a trailing newline counts. Between prompts the reader pauses and unrefs stdin, so a pipe left open does not keep the process alive. Ctrl+C at the prompt still exits (130) instead of being treated as missing input. The callers already handle a rejected login:firecrawl loginprints the error and exits 1, andinitrecords the failed auth step, continues with the remaining steps, and exits 1 with "Setup incomplete: authentication failed".Before and after, with an empty
HOMEand noFIRECRAWL_API_KEY:This complements #328, which stops
ensureAuthenticated()from reaching the menu without a terminal; this change coversloginandinit, which call the login flow directly. No version bump, so it ships with the next release.Testing
src/__tests__/utils/auth.test.ts: the login menu and manual login reject when stdin ends without input, and a piped API key is still read, with or without a trailing newline, and successive prompts read successive piped lines. Both rejection tests time out without the fix.pnpm test,pnpm type-check,pnpm format:check,pnpm build.Found by Wildfire, Firecrawl's integration testing, while reproducing the failing
cli-setup-mcpandcli-templateschecks without a terminal.