iflytek/astron-agent · error · BusinessException

BOT_UPDATE_FAILED

BOT_UPDATE_FAILED

Error message

BOT_UPDATE_FAILED

What it means

insertBotMarketRecord() throws BOT_UPDATE_FAILED when chatBotMarketMapper.insert(marketRecord) returns 0 rows affected. MyBatis-Plus insert returning 0 means the new chat_bot_market record was not persisted (constraint violation swallowed, SQL failure reported as 0 affected rows, or no row inserted).

Solutions

  1. Check for an existing chat_bot_market row for the botId first and update instead of inserting (upsert semantics)
  2. Inspect DB constraints/unique indexes on chat_bot_market and enable SQL logging to see why the insert affected 0 rows
  3. Verify the ChatBotMarket entity mapping (table name, columns, NOT NULL columns all populated) matches the schema
  4. If the insert result is unreliable in your driver/DB, rely on exceptions rather than the affected-row count to detect failure

Example fix

// before
int insertCount = chatBotMarketMapper.insert(marketRecord);
if (insertCount == 0) throw new BusinessException(ResponseEnum.BOT_UPDATE_FAILED);
// after
ChatBotMarket existing = chatBotMarketMapper.selectByBotId(botId);
if (existing != null) { /* update existing row */ } else {
    int insertCount = chatBotMarketMapper.insert(marketRecord);
    if (insertCount == 0) throw new BusinessException(ResponseEnum.BOT_UPDATE_FAILED);
}
Defensive patterns

Strategy: try-catch

Validate before calling

ChatBotMarket existing = chatBotMarketMapper.selectByBotId(botId);
boolean alreadyPresent = existing != null;

Try / catch

try {
    marketPublishStrategy.handleBotMarketSync(botId, uid, spaceId);
} catch (BusinessException e) {
    if ("BOT_UPDATE_FAILED".equals(e.getCode())) {
        // inspect chat_bot_market constraints / duplicate rows and retry as update
    } else throw e;
}

Prevention

When it happens

Trigger: Inserting a chat_bot_market row whose bot_id already exists under a unique key, or a DB-level insert failure causing MyBatis to report 0 affected rows during handleBotMarketSync.

Common situations: Duplicate market record from a previous partial publish (unique index on bot_id/space); schema mismatch between entity fields and table columns; DB trigger or strict mode rejecting the row.

Related errors


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

Appendix: source

Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/strategy/publish/impl/MarketPublishStrategy.java:219

        marketRecord.setOpenedTool(botBase.getOpenedTool());

        // Market-specific fields with defaults
        marketRecord.setShowIndex(0);
        marketRecord.setShowOthers(0);
        marketRecord.setHotNum(0);
        marketRecord.setShowWeight(0);

        // Status and channel management
        marketRecord.setBotStatus(status);
        marketRecord.setPublishChannels(channels);
        marketRecord.setIsDelete(0);
        marketRecord.setCreateTime(LocalDateTime.now());
        marketRecord.setUpdateTime(LocalDateTime.now());

        // Insert record
        int insertCount = chatBotMarketMapper.insert(marketRecord);
        if (insertCount == 0) {
            throw new BusinessException(ResponseEnum.BOT_UPDATE_FAILED);
        }

        log.info("Created bot market record: botId={}, version={}, status={}, channels={}",
                botId, botBase.getVersion(), status, channels);
    }

    /**
     * Sync bot data from chat_bot_base to chat_bot_market (for existing records) When re-publishing,
     * sync all latest data to ensure consistency
     */
    private void syncBotDataToMarket(Integer botId, String uid, Long spaceId, Integer newStatus, String newChannels) {
        // Query latest bot data
        ChatBotBase botBase = chatBotBaseMapper.selectById(botId);
        if (botBase == null) {
            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
        }

        // Build update wrapper to sync all data fields

View on GitHub (pinned to 5e758547a8)