{"record":{"id":"08cf52fc5a01b197","repo":"langgenius/dify","slug":"notloggedin","errorCode":"NotLoggedIn","errorMessage":"no credential stored for ${target} on ${host}","messagePattern":"no credential stored for (.+?) on (.+?)","errorType":"error_code","errorClass":"BaseError","httpStatus":null,"severity":"error","filePath":"cli/src/commands/use/account/use-account.ts","lineNumber":41,"sourceCode":"  const cs = colorScheme(colorEnabled(opts.io.isErrTTY))\n  const reg = await Registry.load()\n  if (reg.current_host === undefined) throw notLoggedInError(USE_HOST_HINT)\n  const host = reg.current_host\n  const entry = reg.hosts[host]\n  if (entry === undefined) throw notLoggedInError(USE_HOST_HINT)\n\n  const emails = Object.keys(entry.accounts)\n  const target = opts.email ?? (await pickAccount(opts, entry, host))\n  if (!emails.includes(target)) {\n    throw new BaseError({\n      code: ErrorCode.UsageInvalidFlag,\n      message: `unknown account \"${target}\" on ${host}; known: ${emails.join(', ')}`,\n    })\n  }\n\n  const store = opts.store ?? getTokenStore(reg.token_storage)\n  if ((await store.read(host, target)) === '') {\n    throw new BaseError({\n      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) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/commands/use/account/use-account.ts#L23-L59","documentation":"Thrown by `runUseAccount` (use/account/use-account.ts:41) as `not_logged_in` (exit 4, Auth) when the selected account exists in the Registry but the token store has no credential for it on that host (`store.read(host, target) === ''`). Distinct from error 35: the account is known but not authenticated. The hint points to `difyctl auth login --host <host>`.","triggerScenarios":"An account entry exists in `hosts[host].accounts` (so error 35 passes) but its stored token is empty — e.g. the credential was cleared, the keyring entry was deleted, or login was never completed for this account on this host.","commonSituations":"OS keyring was reset/cleared; token revoked or expired and removed; account added to registry by a sync but never logged in here; token store backend changed.","solutions":["Re-authenticate: `difyctl auth login --host <host>` (selecting that account).","If using a keyring backend, verify it is accessible (not locked/disabled).","Confirm the token store type in the Registry matches what holds the credential."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const store = getTokenStore(reg.token_storage)\nconst hasCred = (await store.read(host, target)) !== ''","typeGuard":null,"tryCatchPattern":"try {\n  await runUseAccount(opts)\n} catch (err) {\n  if (err instanceof BaseError && err.code === ErrorCode.NotLoggedIn) {\n    // run `difyctl auth login --host <host>` then retry\n  }\n  throw err\n}","preventionTips":["Run `difyctl auth login --host <host>` to populate the credential for the account.","Verify the OS keyring is unlocked and accessible.","Confirm the token store backend in the Registry matches where credentials live."],"tags":["cli","auth","accounts","credentials","difyctl","typescript"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}