{"record":{"id":"5e1e8746140d437f","repo":"immich-app/immich","slug":"user-does-not-exist","errorCode":null,"errorMessage":"User does not exist","messagePattern":"User does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/src/services/cli.service.ts","lineNumber":156,"sourceCode":"      action: {\n        action: MaintenanceAction.Start,\n      },\n    });\n\n    await this.appRepository.sendOneShotAppRestart({\n      isMaintenanceMode: true,\n    });\n\n    return {\n      authUrl: await createMaintenanceLoginUrl(baseUrl, payload, secret),\n      alreadyEnabled: false,\n    };\n  }\n\n  async grantAdminAccess(email: string): Promise<void> {\n    const user = await this.userRepository.getByEmail(email);\n    if (!user) {\n      throw new Error('User does not exist');\n    }\n\n    await this.userRepository.update(user.id, { isAdmin: true });\n  }\n\n  async revokeAdminAccess(email: string): Promise<void> {\n    const user = await this.userRepository.getByEmail(email);\n    if (!user) {\n      throw new Error('User does not exist');\n    }\n\n    await this.userRepository.update(user.id, { isAdmin: false });\n  }\n\n  async disableOAuthLogin(): Promise<void> {\n    const config = await this.getConfig({ withCache: false });\n    config.oauth.enabled = false;\n    await this.updateConfig(config);","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/immich-app/immich/blob/199723261c6ffa897fec8ccdaea6359e39c37cc3/server/src/services/cli.service.ts#L138-L174","documentation":"Thrown (plain Error) by CliService.grantAdminAccess when no user matches the supplied email (userRepository.getByEmail returns null). The grant flow cannot promote a user that does not exist.","triggerScenarios":"Running the CLI command to grant admin access with an email that is not present in the users table.","commonSituations":"Typo in the email argument; wrong database (DATABASE_URL); the target user was deleted; case mismatch in the email.","solutions":["List users first (cli listUsers) and copy the exact email from the output.","Verify DATABASE_URL targets the right instance.","Normalize email case to match what is stored before passing it to the command."],"exampleFix":"// before\nawait cliService.grantAdminAccess(emailArg);\n\n// after\nconst user = await userRepository.getByEmail(emailArg.trim().toLowerCase());\nif (!user) {\n  throw new Error(`No user found for ${emailArg}. Run 'listUsers' to confirm the email.`);\n}\nawait cliService.grantAdminAccess(user.email);","handlingStrategy":"validation","validationCode":"const user = await userRepository.getByEmail(email.trim().toLowerCase());\nif (!user) throw new Error(`No user found for ${email}; run listUsers to verify.`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run listUsers and copy the exact email before grant/revoke commands.","Normalize email case to match stored values.","Verify the CLI talks to the correct database via DATABASE_URL."],"tags":["cli","admin","user"],"backgroundTag":null,"analyzedSha":"199723261c6ffa897fec8ccdaea6359e39c37cc3","analyzedAt":"2026-08-12T04:54:27.085Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}