langgenius/dify · error · BaseError
UsageMissingArg
UsageMissingArg
Error message
--email is required (no TTY); known accounts on ${host}: ${emails.join(', ')} What it means
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.
Source
Thrown at cli/src/commands/use/account/use-account.ts:60
code: ErrorCode.NotLoggedIn,
message: `no credential stored for ${target} on ${host}`,
hint: `run 'difyctl auth login --host ${host}'`,
})
}
reg.setAccount(target)
await reg.save()
opts.io.out.write(`${cs.successIcon()} Active account on ${host} is now ${target}\n`)
}
async function pickAccount(
opts: UseAccountOptions,
entry: HostEntry,
host: string,
): Promise<string> {
const emails = Object.keys(entry.accounts)
if (!opts.io.isErrTTY) {
throw new BaseError({
code: ErrorCode.UsageMissingArg,
message: `--email is required (no TTY); known accounts on ${host}: ${emails.join(', ')}`,
})
}
const choices: AccountChoice[] = Object.entries(entry.accounts).map(([email, ctx]) => ({
email,
name: ctx.account.name,
sso: ctx.external_subject !== undefined,
active: entry.current_account === email,
}))
const picked = await selectFromList<AccountChoice>({
io: opts.io,
items: choices,
header: `Select an account on ${host}`,
render: (c) =>
`${c.active ? '* ' : ' '}${c.email} ${c.sso ? '(SSO)' : c.name !== '' ? `(${c.name})` : ''}`.trimEnd(),
})
return picked.emailView on GitHub (pinned to ef8544b173)
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.
Example fix
// before $ difyctl use account | jq . // after $ difyctl use account --email alice@example.com | jq .
Defensive patterns
Strategy: validation
Validate before calling
// In non-interactive contexts, require --email up front.
function requireEmailForNonTty(isTty: boolean, email?: string): void {
if (!isTty && !email) throw new Error('--email is required when not a TTY')
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Automation/CI scripts that omit `--email`; piping output to a file; running over SSH without TTY allocation; Docker/container runs without `-it`.
Related errors
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/519f710a1841a2ad.
Report an issue: GitHub.