iflytek/astron-agent · warning

Conversation statistics record failed: chatId=

Error message

Conversation statistics record failed: chatId={}

What it means

A warn log when the insert of a conversation statistics row into the DB affects 0 rows, meaning the stat record was not persisted. The method deliberately swallows exceptions so the main publish/chat flow is unaffected, so this only degrades analytics.

Solutions

  1. Check DB logs and table constraints on bot_conversation_stats for why the insert silently affected 0 rows
  2. Log the full entity and SQL at debug level when result <= 0 to expose the cause
  3. Confirm the stats table schema matches the conversationStats entity fields

Example fix

// before
} else {
    log.warn("Conversation statistics record failed: chatId={}", chatId);
}
// after
} else {
    log.warn("Conversation statistics record failed: chatId={}, stats={}", chatId, JSON.toJSONString(conversationStats));
}
Defensive patterns

Strategy: try-catch

When it happens

Trigger: botConversationStatsMapper.insert returns 0 — e.g. DB constraint violation handled silently, connection issue caught upstream, or mapper returning 0 on conflict.

Common situations: Stats table schema changed (new NOT NULL column); duplicate chatId violating unique key; transient DB connectivity problems during high-traffic dashboard writes.

Related errors


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

Appendix: source

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

        log.info("Record conversation statistics: uid={}, spaceId={}, botId={}, chatId={}, tokenConsumed={}",
                uid, spaceId, botId, chatId, tokenConsumed);

        try {
            BotConversationStats conversationStats = BotConversationStats.createBuilder()
                    .uid(uid)
                    .spaceId(spaceId)
                    .botId(botId)
                    .chatId(chatId)
                    .sid(sid)
                    .tokenConsumed(tokenConsumed)
                    .build();
            int result = botConversationStatsMapper.insert(conversationStats);

            if (result > 0) {
                log.info("Conversation statistics recorded successfully: chatId={}, statsId={}", chatId, conversationStats.getId());

            } else {
                log.warn("Conversation statistics record failed: chatId={}", chatId);
            }
        } catch (Exception e) {
            log.error("Record conversation statistics exception: chatId={}", chatId, e);
            // Do not throw exception to avoid affecting main business flow
        }
    }

    // ==================== Private Helper Methods ====================

    /**
     * Validate bot permission
     */
    private void validateBotPermission(Integer botId, String uid, Long spaceId) {
        Integer count = chatBotBaseMapper.checkBotPermission(botId, uid, spaceId);
        if (count == null || count == 0) {
            throw new BusinessException(ResponseEnum.BOT_NOT_EXISTS);
        }
    }

View on GitHub (pinned to 5e758547a8)