langgenius/dify · error · BaseError
UsageInvalidFlag
UsageInvalidFlag
Error message
unknown account "${target}" on ${host}; known: ${emails.join(', ')} What it means
Thrown by `runUseAccount` (use/account/use-account.ts:33) as `usage_invalid_flag` (exit 2) when the resolved `--email` target is not among the accounts registered for the current host in the local Registry. The message lists all known emails for that host to aid correction. Fires after host validation but before credential lookup.
Source
Thrown at cli/src/commands/use/account/use-account.ts:33
readonly store?: TokenStore
}
type AccountChoice = { email: string; name: string; sso: boolean; active: boolean }
const USE_HOST_HINT = "run 'difyctl use host' or 'difyctl auth login'"
export async function runUseAccount(opts: UseAccountOptions): Promise<void> {
const cs = colorScheme(colorEnabled(opts.io.isErrTTY))
const reg = await Registry.load()
if (reg.current_host === undefined) throw notLoggedInError(USE_HOST_HINT)
const host = reg.current_host
const entry = reg.hosts[host]
if (entry === undefined) throw notLoggedInError(USE_HOST_HINT)
const emails = Object.keys(entry.accounts)
const target = opts.email ?? (await pickAccount(opts, entry, host))
if (!emails.includes(target)) {
throw new BaseError({
code: ErrorCode.UsageInvalidFlag,
message: `unknown account "${target}" on ${host}; known: ${emails.join(', ')}`,
})
}
const store = opts.store ?? getTokenStore(reg.token_storage)
if ((await store.read(host, target)) === '') {
throw new BaseError({
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`)
}View on GitHub (pinned to ef8544b173)
Solutions
- Pick an email from the message's `known:` list.
- If the intended account is missing, log in on this host: `difyctl auth login --host <host>`.
- Switch to the correct host first: `difyctl use host <host>`.
Example fix
// before $ difyctl use account --email wrong@example.com // after $ difyctl use account --email alice@example.com
Defensive patterns
Strategy: validation
Validate before calling
const reg = await Registry.load()
const emails = Object.keys(reg.hosts[host]?.accounts ?? {})
function isKnownAccount(email: string): boolean {
return emails.includes(email)
} Prevention
- Choose the email from the registry's known list for the current host.
- Log in on the host first if the account is missing: `difyctl auth login --host <host>`.
- Switch to the correct host with `difyctl use host` before selecting an account.
When it happens
Trigger: Running `difyctl use account --email wrong@example.com` (or selecting an email not in the registry) on a host where that email was never logged in. `emails.includes(target)` is false at line 32.
Common situations: Typo in the email; using the wrong host's account list; the account was logged in on a different host; SSO email differs from the typed one; registry out of date.
Related errors
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/1a5cb89459463f50.
Report an issue: GitHub.