yikart/AiToEarn · error · AppHttpException

ErrHttpBack.err_user_pop_code_null

ErrHttpBack.err_user_pop_code_null

Error message

err_user_pop_code_null

What it means

loginByPhoneCode accepts an optional inviteCode; if provided, it looks up the inviter by popularize code, and err_user_pop_code_null is thrown when no user owns that invite code — registration is blocked rather than silently dropping the referral.

Solutions

  1. Correct the invite code against the inviter's actual code
  2. Retry registration without the inviteCode (it is optional)
  3. Regenerate/share a fresh invite link from the inviter's account

Example fix

// before
await loginApi.loginByPhoneCode(phone, code, inviteCodeTyped); // typo
// after
try {
  await loginApi.loginByPhoneCode(phone, code, inviteCodeTyped);
} catch (e) {
  await loginApi.loginByPhoneCode(phone, code, undefined); // register w/o invite
}
Defensive patterns

Strategy: validation

Validate before calling

if (inviteCode) {
  const inviter = await userService.getUserByPopularizeCode(inviteCode);
  if (!inviter) inviteCode = undefined; // drop invalid invite before login
}

Type guard

function hasInvite(code?: string): code is string {
  return typeof code === 'string' && code.trim().length > 0;
}

Try / catch

try {
  await loginApi.loginByPhoneCode(phone, code, inviteCode);
} catch (e) {
  if (e.response?.message === 'err_user_pop_code_null') {
    await loginApi.loginByPhoneCode(phone, code, undefined);
  }
}

Prevention

When it happens

Trigger: POST phone-code login with an inviteCode that doesn't match any user's popularize code.

Common situations: User hand-typed an invite code with a typo; copied invite link truncated; inviter account deleted after sharing the code; sharing codes across environments with different user bases.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/2af7e2223512c150. Report an issue: GitHub.

Appendix: source

Thrown at project/aitoearn-electron/server/src/user/userLogin.controller.ts:84

  }

  @ApiOperation({
    description: '手机号验证码登录',
    summary: '手机号验证码登录',
  })
  @Public()
  @Post('login/code/phone')
  async loginByPhoneCode(
    @Body(new ParamsValidationPipe()) loginInfo: PhoneLoginByCodeDto,
  ) {
    const { phone, code, inviteCode } = loginInfo;

    // 邀请码验证
    if (!!inviteCode) {
      const inviteUserInfo =
        await this.userService.getUserByPopularizeCode(inviteCode);
      if (!inviteUserInfo)
        throw new AppHttpException(ErrHttpBack.err_user_pop_code_null);
    }

    // 验证短信验证码
    if (process.env.NODE_ENV !== 'development' && code !== 'yika888666') {
      const res = await this.loginService.verifyPhoneCode(
        phone,
        code,
        LoginTypeCacheKey.Code,
      );
      if (!res) throw new AppHttpException(ErrHttpBack.err_user_code_nohad);
    }

    let userInfo: User = await this.userService.getUserInfoByPhone(phone);
    if (!userInfo) {
      const newUser = new NewUserByPhone(phone);
      if (!!inviteCode) newUser.inviteCode = inviteCode;
      userInfo = await this.userService.createUser(newUser);
    }

View on GitHub (pinned to d3aa8bea5b)