jeecgboot/JeecgBoot · error · JeecgBootException
500
500
Error message
租户不存在!
What it means
Identical guard to error 260 but for WeChat Enterprise (企业微信) OAuth login in ThirdAppWechatEnterpriseServiceImpl.oauth2Login. The system queries tenantMapper.tenantIzExist(tenantId) and throws JeecgBootException (HTTP 500) when the tenant does not exist. This is the multi-tenant validation that runs before any WeChat Enterprise API call.
Source
Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/ThirdAppWechatEnterpriseServiceImpl.java:1091
if (response.getIntValue(ERR_CODE) == 0) {
//将userTicket也返回,用于获取手机号
String userTicket = response.getString("user_ticket");
String appUserId = response.getString("UserId");
map.put("userTicket",userTicket);
map.put("appUserId",appUserId);
return map;
}
}
return null;
}
/**
* OAuth2登录,成功返回登录的SysUser,失败返回null
*/
public SysUser oauth2Login(String code,Integer tenantId) {
Long count = tenantMapper.tenantIzExist(tenantId);
if(ObjectUtil.isEmpty(count) || 0 == count){
throw new JeecgBootException("租户不存在!");
}
// 代码逻辑说明: [QQYUN-3440]新建企业微信和钉钉配置表,通过租户模式隔离------------
SysThirdAppConfig config = configMapper.getThirdConfigByThirdType(tenantId, MessageTypeEnum.QYWX.getType());
String accessToken = this.getAppAccessToken(config);
if (accessToken == null) {
return null;
}
Map<String,String> map = this.getUserIdByThirdCode(code, accessToken);
if (null != map) {
//企业微信需要通过userTicket获取用户信息
String appUserId = map.get("appUserId");
String userTicket = map.get("userTicket");
// 判断第三方用户表有没有这个人
LambdaQueryWrapper<SysThirdAccount> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysThirdAccount::getThirdUserId, appUserId);
queryWrapper.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
queryWrapper.eq(SysThirdAccount::getTenantId, tenantId);
SysThirdAccount thirdAccount = sysThirdAccountService.getOne(queryWrapper);View on GitHub (pinned to 96fb33f5ec)
Solutions
- Inspect the login request payload in browser DevTools to confirm the tenantId value being sent.
- Verify the tenant exists: SELECT id, name, status FROM sys_tenant WHERE id = <tenantId>.
- If using a single-tenant setup, ensure the default tenant (ID 0 or 1) is used and seeded in the database.
- Configure the frontend WeChat Enterprise login flow to always include a valid, existing tenantId from the tenant selector or system config.
Example fix
// before: no pre-check on tenantId before OAuth redirect
window.location.href = `${wechatOAuthUrl}?appid=CORPID&redirect_uri=CALLBACK`;
// after: validate tenantId is set before initiating WeChat OAuth
if (!tenantId) {
message.error('租户信息缺失,无法登录');
return;
}
window.location.href = `${wechatOAuthUrl}?appid=CORPID&redirect_uri=CALLBACK&state=${tenantId}`; Defensive patterns
Strategy: validation
Validate before calling
// Before calling oauth2Login, validate tenant existence
public boolean validateTenant(Integer tenantId) {
if (tenantId == null || tenantId <= 0) {
return false;
}
Long count = tenantMapper.tenantIzExist(tenantId);
return count != null && count > 0;
} Type guard
public boolean isValidTenantId(Integer tenantId) {
return tenantId != null && tenantId > 0;
} Try / catch
try {
SysUser user = thirdAppWechatEnterpriseService.oauth2Login(code, tenantId);
if (user == null) {
return Result.error("企业微信登录失败");
}
return Result.OK(user);
} catch (JeecgBootException e) {
if (e.getMessage().contains("租户不存在")) {
return Result.error("租户不存在,请确认租户ID");
}
return Result.error(e.getMessage());
} Prevention
- Ensure the frontend WeChat Enterprise login flow always passes a valid tenantId.
- Seed sys_tenant with at least one valid tenant during deployment.
- Validate tenant existence in the controller layer before calling the service.
- Handle the error gracefully on the frontend with a redirect to the tenant selection page.
When it happens
Trigger: Call oauth2Login(code, tenantId) with a tenantId that has no matching row in sys_tenant. Same triggers as error 260: frontend sends wrong/default tenantId, tenant was deleted, fresh DB without seeded tenant data, or manually crafted URL with invalid tenant parameter.
Common situations: WeChat Enterprise login link was generated for a tenant that was subsequently removed. Multi-tenant deployment where the WeChat Enterprise corp configuration is tenant-specific but the tenantId routing is misconfigured. Frontend tenant selector was bypassed or returned an unexpected value.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/85b2e8a19666b3b9.
Report an issue: GitHub.