langgenius/dify · error · BaseError
UsageMissingArg
UsageMissingArg
Error message
--domain is required (no TTY); known hosts: ${hosts.join(', ')} What it means
Thrown by `pickHost` (use/host/use-host.ts:40) as `usage_missing_arg` (exit 2) when no `--domain` was given AND stderr is not a TTY (non-interactive context), so the interactive host picker cannot run. The message lists known hosts. Mirrors error 37 but for host selection. Fires only on the no-TTY branch.
Source
Thrown at cli/src/commands/use/host/use-host.ts:40
if (!hosts.includes(target)) {
throw new BaseError({
code: ErrorCode.UsageInvalidFlag,
message: `unknown host "${target}"; known hosts: ${hosts.join(', ')}`,
})
}
reg.setHost(target)
await reg.save()
opts.io.out.write(`${cs.successIcon()} Active host is now ${target}\n`)
}
async function pickHost(
opts: UseHostOptions,
reg: Registry,
hosts: readonly string[],
): Promise<string> {
if (!opts.io.isErrTTY) {
throw new BaseError({
code: ErrorCode.UsageMissingArg,
message: `--domain is required (no TTY); known hosts: ${hosts.join(', ')}`,
})
}
const choices: HostChoice[] = hosts.map((h) => ({
host: h,
accounts: Object.keys(reg.hosts[h]?.accounts ?? {}).length,
active: reg.current_host === h,
}))
const picked = await selectFromList<HostChoice>({
io: opts.io,
items: choices,
header: 'Select a host',
render: (c) =>
`${c.active ? '* ' : ' '}${c.host} (${c.accounts} account${c.accounts === 1 ? '' : 's'})`,
})
return picked.host
}View on GitHub (pinned to ef8544b173)
Solutions
- Pass `--domain <host>` explicitly in non-interactive contexts.
- Allocate a TTY for interactive selection (`ssh -t`, `docker run -it`).
- In scripts, resolve the host programmatically and always pass the flag.
Example fix
// before $ difyctl use host < script.sh // after $ difyctl use host --domain api.dify.example < script.sh
Defensive patterns
Strategy: validation
Validate before calling
// In non-interactive contexts, require --domain up front.
function requireHostForNonTty(isTty: boolean, host?: string): void {
if (!isTty && !host) throw new Error('--domain is required when not a TTY')
} Prevention
- Always pass `--domain <host>` in CI, pipes, and scripts.
- Detect TTY in your wrapper and fail fast if absent.
- Allocate a TTY only if interactive host selection is intended.
When it happens
Trigger: Running `difyctl use host` (no `--domain`) inside a pipe, CI, cron, or any non-TTY context. The interactive `selectFromList` is unreachable and the missing-arg error is raised.
Common situations: CI/automation scripts omitting `--domain`; piping output; SSH without TTY; containers without `-it`.
Related errors
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/31313217f1b22a29.
Report an issue: GitHub.