{"record":{"id":"dc3a57a877381a44","repo":"langgenius/dify","slug":"usageinvalidflag-dc3a57","errorCode":"UsageInvalidFlag","errorMessage":"unknown host \"${target}\"; known hosts: ${hosts.join(', ')}","messagePattern":"unknown host \"(.+?)\"; known hosts: (.+?)","errorType":"error_code","errorClass":"BaseError","httpStatus":null,"severity":"error","filePath":"cli/src/commands/use/host/use-host.ts","lineNumber":23,"sourceCode":"import { colorEnabled, colorScheme } from '@/sys/io/color'\nimport { selectFromList } from '@/sys/io/select'\n\nexport type UseHostOptions = {\n  readonly io: IOStreams\n  readonly host: string | undefined\n}\n\ntype HostChoice = { host: string; accounts: number; active: boolean }\n\nexport async function runUseHost(opts: UseHostOptions): Promise<void> {\n  const cs = colorScheme(colorEnabled(opts.io.isErrTTY))\n  const reg = await Registry.load()\n  const hosts = Object.keys(reg.hosts)\n  if (hosts.length === 0) throw notLoggedInError()\n\n  const target = opts.host ?? (await pickHost(opts, reg, hosts))\n  if (!hosts.includes(target)) {\n    throw new BaseError({\n      code: ErrorCode.UsageInvalidFlag,\n      message: `unknown host \"${target}\"; known hosts: ${hosts.join(', ')}`,\n    })\n  }\n\n  reg.setHost(target)\n  await reg.save()\n  opts.io.out.write(`${cs.successIcon()} Active host is now ${target}\\n`)\n}\n\nasync function pickHost(\n  opts: UseHostOptions,\n  reg: Registry,\n  hosts: readonly string[],\n): Promise<string> {\n  if (!opts.io.isErrTTY) {\n    throw new BaseError({\n      code: ErrorCode.UsageMissingArg,","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/commands/use/host/use-host.ts#L5-L41","documentation":"Thrown by `runUseHost` (use/host/use-host.ts:23) as `usage_invalid_flag` (exit 2) when the resolved `--domain` target is not among hosts registered in the local Registry. The message lists all known hosts. Fires after the empty-hosts guard (error: not logged in) but before setting the active host.","triggerScenarios":"Running `difyctl use host wrong.dify.example` where that host was never added via login. `hosts.includes(target)` is false at line 22.","commonSituations":"Typo in the host/domain; using a host name from a different environment (staging vs prod); the host was removed from the registry; wrong scheme/port included.","solutions":["Pick a host from the message's `known hosts:` list.","If the intended host is missing, log in to add it: `difyctl auth login --host <host>`.","Check the registry to see configured hosts before switching."],"exampleFix":"// before\n$ difyctl use host wrong.dify.example\n// after\n$ difyctl use host api.dify.example","handlingStrategy":"validation","validationCode":"const reg = await Registry.load()\nconst hosts = Object.keys(reg.hosts)\nfunction isKnownHost(host: string): boolean {\n  return hosts.includes(host)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick the host from the registry's `known hosts:` list.","Log in to add a new host: `difyctl auth login --host <host>`.","Avoid typos by tab-completing or copying the host from the registry."],"tags":["cli","auth","hosts","registry","difyctl","typescript"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}