{"record":{"id":"d5ea6b71119cc7bd","repo":"yikart/AiToEarn","slug":"errhttpback-err-user-no-had","errorCode":"ErrHttpBack.err_user_no_had","errorMessage":"err_user_no_had","messagePattern":"err_user_no_had","errorType":"error_code","errorClass":"AppHttpException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-electron/server/src/user/user-admin.controller.ts","lineNumber":31,"sourceCode":"import { ErrHttpBack } from '../filters/http-exception.back-code';\nimport { Manager } from '../auth/manager.guard';\n\n@Manager()\n@Controller('admin/user')\nexport class UserAdminController {\n  constructor(private readonly userService: UserService) {}\n\n  // @ApiOperation({ summary: '获取用户列表' })\n  @Get('list')\n  async getUserList(@Query() query: QueryUserListDto) {\n    return this.userService.getUserList(query);\n  }\n\n  // @ApiOperation({ summary: '获取用户详情' })\n  @Get('info/:id')\n  async getUserDetail(@Param('id') id: string) {\n    const userInfo = await this.userService.getUserInfoById(id);\n    if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);\n    return userInfo;\n  }\n\n  // @ApiOperation({ summary: '更新用户状态' })\n  @Put(':id/status')\n  async updateUserStatus(\n    @Param('id') id: string,\n    @Body() body: UpdateUserStatusDto,\n  ) {\n    const userInfo = await this.userService.getUserInfoById(id);\n    if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);\n\n    return this.userService.updateUserStatus(id, body.status);\n  }\n\n  // 删除用户\n  @Delete(':id')\n  async deleteUser(@Param('id') id: string) {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/user/user-admin.controller.ts#L13-L49","documentation":"GET info/:id in the admin controller looks up a user by id via userService.getUserInfoById; if no user row matches, err_user_no_had is thrown to signal an unknown user id to the admin caller.","triggerScenarios":"GET /user/info/:id where :id does not exist in the users table (or refers to a deleted user).","commonSituations":"Stale id cached in an admin UI; id typo; user deleted between listing and detail fetch; passing a phone/email instead of the user id.","solutions":["Verify the id exists (check the users table / list endpoint)","Use a fresh id from the admin user list instead of a stale cached one","Handle the 404-style error in the admin client and refresh the list"],"exampleFix":"// before\nawait adminApi.getUserDetail(id); // throws if user gone\n// after\nconst user = await userService.getUserInfoById(id);\nif (!user) return null; // or show 'user not found' instead of crashing","handlingStrategy":"try-catch","validationCode":"const user = await userService.getUserInfoById(id);\nif (!user) return null; // skip the admin endpoint call","typeGuard":"function isUser(u: User | null | undefined): u is User { return !!u && typeof u.id === 'string'; }","tryCatchPattern":"try {\n  const detail = await adminApi.getUserDetail(id);\n} catch (e) {\n  if (e.response?.message === 'err_user_no_had') refreshUserList();\n}","preventionTips":["Always use ids from a fresh list response","Refresh admin UI after deletions","Don't cache user ids for long periods"],"tags":["user","not-found","admin"],"backgroundTag":"user-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}