iflytek/astron-agent · error · BusinessException
BOT_NOT_EXISTS
BOT_NOT_EXISTS
Error message
BOT_NOT_EXISTS
What it means
MarketPublishStrategy.publish validates that the current user has permission over the bot via chatBotBaseMapper.checkBotPermission(botId, currentUid, spaceId) and throws BOT_NOT_EXISTS when the query returns 0 rows. The code deliberately reuses BOT_NOT_EXISTS to cover both 'bot does not exist' and 'bot not visible/owned in this space', so it is an authorization-shaped not-found error.
Solutions
- Verify the bot exists and that you are its owner (or have publish permission) in the given space.
- Ensure the request's spaceId context matches the space the bot belongs to (SpaceInfoUtil context).
- Re-fetch the bot list for the current space and use a valid botId.
- If legitimate admins need to publish others' bots, extend checkBotPermission to allow space-admin roles.
Example fix
// before
marketPublish(botIdFromOtherSpace, uid, currentSpaceId); // permission check returns 0
// after
Bot b = botService.getBotInSpace(botId, currentSpaceId);
if (b == null) throw new BizError("bot not available in this space");
marketPublish(b.getId(), uid, currentSpaceId); Defensive patterns
Strategy: validation
Validate before calling
Integer perm = chatBotBaseMapper.checkBotPermission(botId, currentUid, spaceId);
if (perm == null || perm == 0) {
throw new AccessDeniedException("bot " + botId + " not found or not owned by user in space " + spaceId);
} Type guard
boolean canManageBot(Long botId, String uid, Long spaceId) {
return botId != null && chatBotBaseMapper.checkBotPermission(botId, uid, spaceId) > 0;
} Try / catch
try {
marketPublishStrategy.publish(botId, uid, spaceId);
} catch (BusinessException e) {
if ("BOT_NOT_EXISTS".equals(e.getCode())) {
refreshBotListForSpace(spaceId); // wrong id, wrong space, or no ownership
}
throw e;
} Prevention
- Keep the uid/spaceId context in sync when the user switches spaces
- Derive botId from a space-scoped bot list, never from stale client state
- Hide publish actions for bots the current user doesn't own
When it happens
Trigger: Calling the market publish endpoint with a botId that doesn't exist, a bot belonging to another space (spaceId mismatch), or a currentUid that is not the bot owner — checkBotPermission returns 0 and the error is thrown before any status query.
Common situations: Caller passes a botId from a different space; uid/spaceId context lost after switching spaces in the UI; attempting to publish someone else's bot; bot hard-deleted while the client still shows it.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/206e2dde353985b6.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/strategy/publish/impl/MarketPublishStrategy.java:49
@Component
@RequiredArgsConstructor
public class MarketPublishStrategy implements PublishStrategy {
private final ChatBotBaseMapper chatBotBaseMapper;
private final ChatBotMarketMapper chatBotMarketMapper;
private final PublishChannelService publishChannelService;
private final ApplicationEventPublisher eventPublisher;
@Override
@Transactional(rollbackFor = Exception.class)
public ApiResult<Object> publish(Integer botId, Object publishData, String currentUid, Long spaceId) {
log.info("Publishing bot to market: botId={}, currentUid={}, spaceId={}", botId, currentUid, spaceId);
try {
// 1. Validate bot permission
int hasPermission = chatBotBaseMapper.checkBotPermission(botId, currentUid, spaceId);
if (hasPermission == 0) {
throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
}
// 2. Query current publish status
BotPublishQueryResult queryResult = chatBotMarketMapper.selectBotDetail(botId, currentUid, spaceId);
Integer currentStatus = queryResult != null ? queryResult.getBotStatus() : null;
String currentChannels = queryResult != null ? queryResult.getPublishChannels() : null;
// 3. Calculate new status and channels
Integer effectiveStatus = currentStatus != null ? currentStatus : ShelfStatusEnum.OFF_SHELF.getCode();
// Allow re-publishing even if already on shelf
if (ShelfStatusEnum.isOnShelf(effectiveStatus)) {
log.info("Bot already published, performing re-publish operation: botId={}", botId);
}
if (!ShelfStatusEnum.isOffShelf(effectiveStatus) && !ShelfStatusEnum.isOnShelf(effectiveStatus)) {
throw new BusinessException(ResponseEnum.BOT_STATUS_NOT_ALLOW_PUBLISH);
}View on GitHub (pinned to 5e758547a8)