{"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":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/cli.service.ts","lineNumber":155,"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":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/cli.service.ts#L137-L173","documentation":"`grantAdminAccess` resolves the target user by email via userRepository.getByEmail(email). If no user matches the given email, it throws 'User does not exist' instead of promoting a nonexistent account. This is a plain Error thrown from the CLI service layer.","triggerScenarios":"Running the grant-admin CLI command with an email that has no matching row in the user table, e.g. `immich-admin grant-admin bob@wrongdomain.com`.","commonSituations":"Typos in the email address; user registered with a different email than expected; case/whitespace mismatch; operating against a different database environment (staging vs production).","solutions":["Verify the exact email: list users (or query SELECT email FROM \"user\") and copy the address verbatim.","Check you are connected to the intended database via the CLI environment configuration.","Create the user first if it genuinely does not exist, then run grant-admin again."],"exampleFix":"// before\n$ immich-admin grant-admin Bob@Example.com    // typo in stored email → User does not exist\n// after\n$ immich-admin grant-admin bob@example.com    # exact email as registered","handlingStrategy":"validation","validationCode":"// Confirm the exact registered email before granting admin\nconst users = await api.searchUsers();\nconst target = users.find(u => u.email.toLowerCase() === email.trim().toLowerCase());\nif (!target) throw new Error(`No user with email ${email}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy emails verbatim from the user list instead of retyping them.","Check which database environment the CLI targets before running admin commands.","Normalize emails (lowercase, trim) on registration to avoid mismatches."],"tags":["cli","user-management","email-lookup","not-found"],"backgroundTag":"user-not-found","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}