ruvnet/ruflo · warning · LoginCancelledError

login cancelled: no code was entered

Error message

login cancelled: no code was entered

What it means

Thrown by the manual/headless login path (LoginCancelledError) when the user enters an empty code or closes stdin before entering one. The readline race against the 'close' event converts EOF to an empty string, which is treated as an explicit cancellation rather than a hang.

Source

Thrown at v3/@claude-flow/cli/src/auth/client.ts:165

  const pkce = sec.generatePkce();
  const url = sec.authorizeUrl(sec.OOB_REDIRECT_URI, pkce.state, pkce.codeChallenge);
  print(`Open this URL in a browser and authorize:\n\n  ${url}\n`);

  // `rl.question()` resolves on a newline-terminated 'line' event — if `input`
  // ends without ever emitting one (e.g. stdin closed early, or piped input
  // with no trailing newline), it hangs forever rather than treating EOF as
  // a cancellation. Race it against the interface's own 'close' event so an
  // early EOF resolves to "" (-> LoginCancelledError below) instead of hanging.
  const rl = readline.createInterface({ input, terminal: false });
  let code: string;
  try {
    const closed = new Promise<string>((resolve) => rl.once('close', () => resolve('')));
    code = (await Promise.race([rl.question('Paste the code shown after authorizing: '), closed])).trim();
  } finally {
    rl.close();
  }
  if (!code) throw new LoginCancelledError();

  const tokens = await sec.exchangeManualCode(code, pkce.codeVerifier);
  return { tokens, method: 'device' };
}

/**
 * `--token-stdin`: reads one JSON object from stdin,
 * `{access_token, refresh_token?, expires_in, scope}`. Wire format is not
 * specified by ADR-306 — defined here as typed JSON rather than a bare
 * token string, so scope/expiry are explicit rather than inferred.
 */
export async function tokenStdinLogin(input: NodeJS.ReadableStream = process.stdin): Promise<LoginResult> {
  const chunks: Buffer[] = [];
  for await (const chunk of input) chunks.push(chunk as Buffer);
  const raw = Buffer.concat(chunks).toString('utf-8').trim();
  if (!raw) throw new Error('--token-stdin: no input received on stdin');

  let parsed: { access_token?: string; refresh_token?: string; expires_in?: number; scope?: string };

View on GitHub (pinned to 6b01dc5a68)

Solutions

  1. Re-run the login and paste the full code from the authorize page.
  2. In scripts, ensure stdin is a pipe that actually contains the code with a trailing newline.
Defensive patterns

Strategy: validation

Validate before calling

const code = (await readLine()).trim();
if (code.length === 0) {
  console.error('No code entered. Re-run and paste the code from the authorize page.');
  process.exit(1);
}

Try / catch

try {
  await manualLogin(print, input);
} catch (e) {
  if (e instanceof Error && /no code was entered|login cancelled/.test(e.message)) {
    // user-initiated cancel; exit 0 or re-prompt
  } else throw e;
}

Prevention

When it happens

Trigger: Calling manualLogin and the user presses Enter at the 'Paste the code' prompt with nothing typed, or stdin reaches EOF (piped input ended without a code).

Common situations: User aborted; piped input was empty or malformed; non-interactive shell with no tty and no input.

Related errors


AI-assisted analysis of ruvnet/ruflo@6b01dc5a68 (2026-08-12). Data as JSON: /api/errors/ed4ecb6e17f20418. Report an issue: GitHub.