{"record":{"id":"b8e268656fc6112b","repo":"immich-app/immich","slug":"admin-account-does-not-exist","errorCode":null,"errorMessage":"Admin account does not exist","messagePattern":"Admin account does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/services/cli.service.ts","lineNumber":66,"sourceCode":"      }\n    }\n\n    const drift = await this.databaseRepository.getSchemaDrift();\n\n    return { migrations, drift };\n  }\n\n  async listUsers(): Promise<UserAdminResponseDto[]> {\n    const users = await this.userRepository.getList({ withDeleted: true });\n    return users.map((user) => mapUserAdmin(user));\n  }\n\n  async resetAdminPassword(\n    ask: (admin: UserAdminResponseDto) => Promise<{ newPassword: string | undefined; invalidateSessions: boolean }>,\n  ) {\n    const admin = await this.userRepository.getAdmin();\n    if (!admin) {\n      throw new Error('Admin account does not exist');\n    }\n\n    const { newPassword: providedPassword, invalidateSessions } = await ask(mapUserAdmin(admin));\n    const password = providedPassword || this.cryptoRepository.randomBytesAsText(24);\n    const hashedPassword = await this.cryptoRepository.hashBcrypt(password, SALT_ROUNDS);\n\n    await this.userRepository.update(admin.id, { password: hashedPassword });\n\n    if (invalidateSessions) {\n      await this.sessionRepository.invalidateAll({ userId: admin.id });\n    }\n\n    return { admin, password, provided: !!providedPassword };\n  }\n\n  async disablePasswordLogin(): Promise<void> {\n    const config = await this.getConfig({ withCache: false });\n    config.passwordLogin.enabled = false;","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/immich-app/immich/blob/199723261c6ffa897fec8ccdaea6359e39c37cc3/server/src/services/cli.service.ts#L48-L84","documentation":"Thrown (as a plain Error, not an HTTP exception) by CliService.resetAdminPassword when userRepository.getAdmin() returns null. The CLI admin-password-reset flow assumes an admin already exists; on an unbootstrapped system there is nothing to reset.","triggerScenarios":"Running the CLI command that resets the admin password against a database that has no admin user (fresh install, wiped DB, or partial migration).","commonSituations":"Running the reset-admin-password CLI before initial onboarding; against a database restored from a dump that lacked the admin row; wrong DATABASE_URL pointing at an empty schema.","solutions":["Bootstrap the instance first (create the initial admin via the web setup flow or setup CLI).","Confirm DATABASE_URL points at the intended database that actually contains the admin user.","If the admin was deleted, recreate one before attempting a password reset."],"exampleFix":"// before\nawait cliService.resetAdminPassword(prompt);\n\n// after\nconst admin = await userRepository.getAdmin();\nif (!admin) {\n  console.error('No admin account found. Complete initial setup first.');\n  process.exit(1);\n}\nawait cliService.resetAdminPassword(prompt);","handlingStrategy":"validation","validationCode":"if (!(await userRepository.hasAdmin())) {\n  console.error('No admin account; complete initial setup before resetting password.');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm DATABASE_URL points at the populated database before running CLI admin tools.","Complete onboarding (create an admin) before invoking resetAdminPassword.","Script the CLI to check for an admin first and exit cleanly if absent."],"tags":["cli","admin","bootstrap"],"backgroundTag":null,"analyzedSha":"199723261c6ffa897fec8ccdaea6359e39c37cc3","analyzedAt":"2026-08-12T04:54:27.085Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}