iflytek/astron-agent · error · BusinessException
INVITE_ADD_TEAM_USER_FAILED
INVITE_ADD_TEAM_USER_FAILED
Error message
INVITE_ADD_TEAM_USER_FAILED
What it means
INVITE_ADD_TEAM_USER_FAILED is thrown during enterprise creation when the enterprise record is saved but adding the creator as the enterprise super admin (EnterpriseRoleEnum.OFFICER) fails. The enterprise would otherwise be created without any owner, so the operation is aborted with this error.
Solutions
- Check for an existing enterprise-user row for this user and clean orphans
- Retry enterprise creation with a fresh org/enterprise ID
- Inspect enterpriseUserService logs and the enterprise-user table for the write failure
- Wrap save + addEnterpriseUser in one transaction so partial state can't persist
Example fix
// before
enterpriseService.save(enterprise);
if (!enterpriseUserService.addEnterpriseUser(id, uid, OFFICER)) { throw ... }
// after
@Transactional
if (enterpriseService.save(enterprise)
&& enterpriseUserService.addEnterpriseUser(enterprise.getId(), enterprise.getUid(), EnterpriseRoleEnum.OFFICER)) {
return ApiResult.success(enterprise.getId());
} Defensive patterns
Strategy: try-catch
Validate before calling
if (enterpriseUserService.getEnterpriseUser(enterpriseId, creatorUid) != null) { /* already officer; skip add */ } Try / catch
try { enterpriseService.create(...); } catch (BusinessException e) { if ("INVITE_ADD_TEAM_USER_FAILED".equals(e.getMessage())) { /* clean up orphan enterprise record, then retry */ } } Prevention
- Save enterprise and add owner in a single transaction
- Clean up partial state on failure (compensating delete of the enterprise)
- Check for pre-existing membership rows before insert
When it happens
Trigger: enterpriseUserService.addEnterpriseUser(enterpriseId, creatorUid, OFFICER) returns false right after a successful enterpriseService.save — typically a duplicate membership row or a DB write failure.
Common situations: Retry after partial failure leaving an orphan enterprise-user row; user account deleted concurrently; DB constraint or connection errors on the enterprise-user table.
Related errors
- INVITE_ADD_TEAM_USER_FAILED
- 8522
- begin tenant bootstrap transaction failed
- commit tenant bootstrap transaction failed
- INVITE_ADD_SPACE_USER_FAILED
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/bdf13bef89ec9e5c.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/space/impl/EnterpriseBizServiceImpl.java:83
}
if (enterpriseService.checkExistByName(enterpriseAddDTO.getName(), null)) {
return ApiResult.error(ResponseEnum.ENTERPRISE_NAME_EXISTS);
}
if (enterpriseService.checkExistByUid(uid)) {
return ApiResult.error(ResponseEnum.ENTERPRISE_USER_ALREADY_CREATED_ENTERPRISE);
}
// Save team data
Enterprise enterprise = new Enterprise();
enterprise.setName(enterpriseAddDTO.getName());
enterprise.setAvatarUrl(enterpriseAddDTO.getAvatarUrl());
enterprise.setUid(uid);
enterprise.setOrgId(IdWorker.getId());
enterprise.setServiceType(enterpriseResult.getServiceType().getCode());
enterprise.setExpireTime(enterpriseResult.getEndTime());
if (enterpriseService.save(enterprise)) {
// Creator becomes enterprise super admin by default
if (!enterpriseUserService.addEnterpriseUser(enterprise.getId(), enterprise.getUid(), EnterpriseRoleEnum.OFFICER)) {
throw new BusinessException(ResponseEnum.INVITE_ADD_TEAM_USER_FAILED);
}
return ApiResult.success(enterprise.getId());
}
return ApiResult.error(ResponseEnum.ENTERPRISE_CREATE_FAILED);
}
/**
* Update team name
*
* @param name
* @return
*/
@Override
@Transactional
public ApiResult<String> updateName(String name) {
Long enterpriseId = EnterpriseInfoUtil.getEnterpriseId();
if (enterpriseService.checkExistByName(name, enterpriseId)) {
return ApiResult.error(ResponseEnum.ENTERPRISE_NAME_EXISTS);View on GitHub (pinned to 5e758547a8)