{"record":{"id":"519f710a1841a2ad","repo":"langgenius/dify","slug":"usagemissingarg-519f71","errorCode":"UsageMissingArg","errorMessage":"--email is required (no TTY); known accounts on ${host}: ${emails.join(', ')}","messagePattern":"--email is required \\(no TTY\\); known accounts on (.+?): (.+?)","errorType":"error_code","errorClass":"BaseError","httpStatus":null,"severity":"error","filePath":"cli/src/commands/use/account/use-account.ts","lineNumber":60,"sourceCode":"      code: ErrorCode.NotLoggedIn,\n      message: `no credential stored for ${target} on ${host}`,\n      hint: `run 'difyctl auth login --host ${host}'`,\n    })\n  }\n\n  reg.setAccount(target)\n  await reg.save()\n  opts.io.out.write(`${cs.successIcon()} Active account on ${host} is now ${target}\\n`)\n}\n\nasync function pickAccount(\n  opts: UseAccountOptions,\n  entry: HostEntry,\n  host: string,\n): Promise<string> {\n  const emails = Object.keys(entry.accounts)\n  if (!opts.io.isErrTTY) {\n    throw new BaseError({\n      code: ErrorCode.UsageMissingArg,\n      message: `--email is required (no TTY); known accounts on ${host}: ${emails.join(', ')}`,\n    })\n  }\n  const choices: AccountChoice[] = Object.entries(entry.accounts).map(([email, ctx]) => ({\n    email,\n    name: ctx.account.name,\n    sso: ctx.external_subject !== undefined,\n    active: entry.current_account === email,\n  }))\n  const picked = await selectFromList<AccountChoice>({\n    io: opts.io,\n    items: choices,\n    header: `Select an account on ${host}`,\n    render: (c) =>\n      `${c.active ? '* ' : '  '}${c.email}  ${c.sso ? '(SSO)' : c.name !== '' ? `(${c.name})` : ''}`.trimEnd(),\n  })\n  return picked.email","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/commands/use/account/use-account.ts#L42-L78","documentation":"Thrown by `pickAccount` (use/account/use-account.ts:60) as `usage_missing_arg` (exit 2) when no `--email` was given AND stdout is not a TTY (non-interactive context), so the interactive account picker cannot run. The message lists known accounts to guide the caller. Fires only on the no-TTY branch of the picker.","triggerScenarios":"Running `difyctl use account` (no `--email`) inside a pipe, CI, cron, redirected output, or any context where `io.isErrTTY` is false. The interactive `selectFromList` is skipped and the missing-arg error is raised.","commonSituations":"Automation/CI scripts that omit `--email`; piping output to a file; running over SSH without TTY allocation; Docker/container runs without `-it`.","solutions":["Pass `--email <account>` explicitly in non-interactive contexts.","Allocate a TTY if interactivity is desired (`ssh -t`, `docker run -it`).","In scripts, resolve the email programmatically and always pass the flag."],"exampleFix":"// before\n$ difyctl use account | jq .\n// after\n$ difyctl use account --email alice@example.com | jq .","handlingStrategy":"validation","validationCode":"// In non-interactive contexts, require --email up front.\nfunction requireEmailForNonTty(isTty: boolean, email?: string): void {\n  if (!isTty && !email) throw new Error('--email is required when not a TTY')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass `--email <account>` in CI, pipes, and scripts.","Detect TTY in your wrapper and fail fast with a clear message if absent.","Allocate a TTY (`ssh -t`, `docker run -it`) only if interactive selection is intended."],"tags":["cli","auth","accounts","non-interactive","missing-arg","difyctl","typescript"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}