yikart/AiToEarn · error · AppHttpException
ErrHttpBack.err_user_no_had
ErrHttpBack.err_user_no_had
Error message
err_user_no_had
What it means
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.
Source
Thrown at project/aitoearn-electron/server/src/user/user-admin.controller.ts:31
import { ErrHttpBack } from '../filters/http-exception.back-code';
import { Manager } from '../auth/manager.guard';
@Manager()
@Controller('admin/user')
export class UserAdminController {
constructor(private readonly userService: UserService) {}
// @ApiOperation({ summary: '获取用户列表' })
@Get('list')
async getUserList(@Query() query: QueryUserListDto) {
return this.userService.getUserList(query);
}
// @ApiOperation({ summary: '获取用户详情' })
@Get('info/:id')
async getUserDetail(@Param('id') id: string) {
const userInfo = await this.userService.getUserInfoById(id);
if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);
return userInfo;
}
// @ApiOperation({ summary: '更新用户状态' })
@Put(':id/status')
async updateUserStatus(
@Param('id') id: string,
@Body() body: UpdateUserStatusDto,
) {
const userInfo = await this.userService.getUserInfoById(id);
if (!userInfo) throw new AppHttpException(ErrHttpBack.err_user_no_had);
return this.userService.updateUserStatus(id, body.status);
}
// 删除用户
@Delete(':id')
async deleteUser(@Param('id') id: string) {View on GitHub (pinned to d3aa8bea5b)
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
Example fix
// before await adminApi.getUserDetail(id); // throws if user gone // after const user = await userService.getUserInfoById(id); if (!user) return null; // or show 'user not found' instead of crashing
Defensive patterns
Strategy: try-catch
Validate before calling
const user = await userService.getUserInfoById(id); if (!user) return null; // skip the admin endpoint call
Type guard
function isUser(u: User | null | undefined): u is User { return !!u && typeof u.id === 'string'; } Try / catch
try {
const detail = await adminApi.getUserDetail(id);
} catch (e) {
if (e.response?.message === 'err_user_no_had') refreshUserList();
} Prevention
- Always use ids from a fresh list response
- Refresh admin UI after deletions
- Don't cache user ids for long periods
When it happens
Trigger: GET /user/info/:id where :id does not exist in the users table (or refers to a deleted user).
Common situations: 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.
Understand the failure class
Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/d5ea6b71119cc7bd.
Report an issue: GitHub.