iflytek/astron-agent · error · BusinessException

BOT_NOT_EXISTS

BOT_NOT_EXISTS

Error message

BOT_NOT_EXISTS

What it means

BOT_NOT_EXISTS in validateApprovalTarget (called by submitIfRequired) is thrown when chatBotBaseMapper.checkBotPermission returns 0, meaning the requester has no access to (or the space has no) the bot identified by resourceId. The approval target bot is missing or inaccessible in the submitted space.

Solutions

  1. Verify the bot exists in the submitted space and the requester has permission.
  2. Correct the resourceId/botId in the submit DTO.
  3. Ensure submitDto.spaceId matches the bot's actual space.
  4. Fix bot ownership or space membership, then re-submit.
Defensive patterns

Strategy: validation

Validate before calling

int hasPermission = chatBotBaseMapper.checkBotPermission(botId, requesterUid, spaceId);
if (hasPermission <= 0) {
    // bot missing or inaccessible in this space; fix before submitting approval
    return;
}

Try / catch

try {
    publishApprovalService.submitIfRequired(submitDto);
} catch (BusinessException e) {
    if ("BOT_NOT_EXISTS".equals(String.valueOf(e.getCode()))) {
        // fix resourceId/spaceId or request access, then resubmit
    }
}

Prevention

When it happens

Trigger: BOT-type publish approval where parseBotId(resourceId) yields a botId for which checkBotPermission(botId, requesterUid, spaceId) <= 0.

Common situations: Bot belongs to a different space than the one submitted; bot deleted; wrong resourceId string from the client; uid/space mismatch in auth context.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/b9c7317e4838e20b. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/PublishApprovalServiceImpl.java:279

    }

    private boolean isOwnerOrAdmin(SpaceRoleEnum role) {
        return SpaceRoleEnum.OWNER == role || SpaceRoleEnum.ADMIN == role;
    }

    private boolean isApprovalEnabledPublishType(PublishApprovalTypeEnum publishType) {
        return PublishApprovalTypeEnum.MARKET == publishType || PublishApprovalTypeEnum.API == publishType;
    }

    private void validateApprovalTarget(PublishApprovalSubmitDto submitDto) {
        if (PublishApprovalResourceTypeEnum.BOT == submitDto.getResourceType()) {
            Integer botId = parseBotId(submitDto.getResourceId());
            int hasPermission = chatBotBaseMapper.checkBotPermission(
                    botId,
                    submitDto.getRequesterUid(),
                    submitDto.getSpaceId());
            if (hasPermission <= 0) {
                throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
            }
        }

        if (PublishApprovalTypeEnum.API == submitDto.getPublishType()
                && (StringUtils.isBlank(submitDto.getTargetId())
                        || appMstService.getByAppId(submitDto.getRequesterUid(), submitDto.getTargetId()) == null)) {
            throw new BusinessException(ResponseEnum.USER_APP_ID_NOT_EXISTE);
        }
    }

    private Integer parseBotId(String resourceId) {
        if (StringUtils.isBlank(resourceId)) {
            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);
        }
        try {
            return Integer.valueOf(resourceId);
        } catch (NumberFormatException e) {
            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);

View on GitHub (pinned to 5e758547a8)