fix(providers): skip interactive re-auth prompt in non-interactive environments - #471
Merged
Merged
Conversation
Single source of truth for "can we prompt the user right now?", based on process.stdin.isTTY. Used to guard interactive prompts (e.g. inquirer) that would otherwise hang or crash (ERR_USE_AFTER_CLOSE) when no TTY is attached to stdin (CI, automation, piped input). Part of EPMCDME-13953.
…vironments handleAuthValidationFailure now checks isNonInteractiveEnvironment() before calling setupSteps.promptForReauth. In a non-interactive context (no TTY), the interactive prompt is skipped entirely and the provider is treated the same way as one with no promptForReauth implementation at all -- printing the actionable failure message and returning a clean, non-hanging result. Fixes the CLI hanging (and crashing with ERR_USE_AFTER_CLOSE) when SSO re-authentication is needed but no TTY is available, e.g. in CI/automation. Fixes EPMCDME-13953.
Adds a "Non-Interactive Environments (CI/Automation)" section to docs/AUTHENTICATION.md explaining the auto-detect fail-fast behavior, its message, and the JWT Bearer Authorization workaround for CI use. Part of EPMCDME-13953.
Spec, plan, technical analysis, complexity assessments, code review verdicts, and QA report for EPMCDME-13953, produced by the sdlc-standard flow. Part of EPMCDME-13953.
TarasSpashchenko
approved these changes
Aug 6, 2026
8nevil8
approved these changes
Aug 7, 2026
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.
Summary
CLI hangs (and crashes with
Error [ERR_USE_AFTER_CLOSE]: readline was closed) when SSOre-authentication is needed but no TTY is attached — e.g. CI, automation, piped invocations. This
fixes it: the shared auth-failure gate now detects a non-interactive environment and fails fast
with a clear message instead of attempting an
inquirerprompt.Changes
feat(utils): newisNonInteractiveEnvironment()utility (src/utils/interactive.ts) — singlesource of truth for
!process.stdin.isTTY.fix(providers):handleAuthValidationFailure(src/providers/core/auth-validation.ts) nowskips
promptForReauthentirely when non-interactive, falling into the same clean-failure pathalready used for providers with no
promptForReauth(e.g. JWT). One edit fixes all three callsites (
AgentCLI.handleRun,cli/commands/profile/index.ts,utils/auth.ts:getAuthenticatedClient)and every current/future
ProviderSetupStepsimplementer.docs: new "Non-Interactive Environments (CI/Automation)" section indocs/AUTHENTICATION.md.chore: SDLC planning artifacts (spec, plan, technical analysis, complexity assessments, codereview verdicts, QA report) under
docs/superpowers/tasks/2026-08-06-non-interactive-sso/.Testing
promptForReauth present/absent, plus a null-setupSteps case)
codemiecall with expired SSO creds hung and crashed withERR_USE_AFTER_CLOSE) before thefix landed
Checklist
npm run cigates: license-check, lint, typecheck, build, unit — 2636 passed,integration — 213 passed)
mainCloses EPMCDME-13953.