# 发生错误 (UserNotFoundException)：调用 AdminGetUser 操作时：未找到用户

- **ID:** `aws/cognito-user-not-found-exception`
- **领域:** aws
- **类别:** auth_error
- **错误码:** `UserNotFoundException`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

指定的用户在 Amazon Cognito 用户池中不存在，可能是因为用户名错误、用户已删除或使用了不同环境的用户池 ID。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Cognito User Pools API 2016-04-18 | active | — | — |
| AWS SDK for JavaScript 3.600.0 | active | — | — |

## 解决方案

1. ```
   Verify the username exists by listing users in the pool: `aws cognito-idp list-users --user-pool-id <pool-id> --query "Users[?Username=='<username>']"`. If missing, re-create the user with `aws cognito-idp admin-create-user --user-pool-id <pool-id> --username <username>`.
   ```
2. ```
   Check that the user pool ID in the request matches the correct environment (dev vs prod) and that the user was not accidentally deleted via AWS Console or API.
   ```

## 无效尝试

- **Re-running the same AdminGetUser call with the same credentials, expecting a different result.** — The user truly does not exist; retrying does not create or recover the user. (100% 失败率)
- **Modifying IAM permissions to allow all cognito-idp actions, assuming it's a permission issue.** — The error is UserNotFoundException, not AccessDenied; permissions are sufficient. (80% 失败率)
