{"record":{"id":"2dcc28a9a4c7d7f3","repo":"iflytek/astron-agent","slug":"system-error-2dcc28","errorCode":"SYSTEM_ERROR","errorMessage":"SYSTEM_ERROR","messagePattern":"SYSTEM_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"critical","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/McpServiceImpl.java","lineNumber":105,"sourceCode":"                .uid(currentUid)\n                .spaceId(spaceId)\n                .serverName(request.getServerName())\n                .description(request.getDescription())\n                .content(request.getContent())\n                .icon(request.getIcon())\n                .serverUrl(serverUrl) // Use server URL from MCP registration\n                .args(request.getArgs())\n                .versionName(versionName)\n                .released(1)\n                .isDelete(0)\n                .createTime(LocalDateTime.now())\n                .updateTime(LocalDateTime.now())\n                .build();\n\n        // 8. Save MCP data\n        int result = mcpDataMapper.insert(mcpData);\n        if (result == 0) {\n            throw new BusinessException(ResponseEnum.SYSTEM_ERROR);\n        }\n\n        // 9. Record the release (corresponds to releaseManageClientService.releaseMCP in original project)\n        recordMcpRelease(botId, versionName, currentUid, spaceId);\n\n        // 10. Update publish channel\n        botPublishService.updatePublishChannel(botId, currentUid, spaceId, PublishChannelEnum.MCP, true);\n\n        log.info(\"MCP published successfully: botId={}, mcpId={}, versionName={}\",\n                botId, mcpData.getId(), versionName);\n    }\n\n    /**\n     * Get version name for MCP publishing (corresponds to\n     * releaseManageClientService.getVersionNameByBotId)\n     */\n    private String getVersionName(Integer botId, String currentUid, Long spaceId) {\n        try {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/McpServiceImpl.java#L87-L123","documentation":"SYSTEM_ERROR is thrown by publishMcp when the MCP data insert (mcpDataMapper.insert) returns 0 rows affected, i.e. MyBatis-Plus inserted nothing. This is a generic persistence failure signal during step 8 of the MCP publish flow and rolls back the whole transaction.","triggerScenarios":"mcp_data insert affects 0 rows — typically DB connection failure, schema mismatch (e.g. missing columns like server_url/args), oversized field values (content/icon exceeding column limits), or a constraint violation surfaced as 0 affected rows.","commonSituations":"content or description longer than the column size; DB schema drifted after an upgrade (new not-null column not populated by the entity); database temporarily unreachable; bad serverUrl from registration making insert fail downstream of step 6.","solutions":["Check service logs and DB connectivity; retry the publish after confirming MySQL is healthy.","Inspect mcp_data schema against the McpData entity for missing/oversized columns; align column lengths with request field limits.","Validate request payload sizes (content/description/icon) before publishing; truncate or enforce limits upstream.","Re-run the publish; the @Transactional(rollbackFor=Exception.class) ensures earlier steps (registration, release) roll back so a retry is safe."],"exampleFix":"// before\nint result = mcpDataMapper.insert(mcpData);\nif (result == 0) { throw new BusinessException(ResponseEnum.SYSTEM_ERROR); }\n// after\ntry {\n    int result = mcpDataMapper.insert(mcpData);\n    if (result == 0) {\n        log.error(\"MCP insert affected 0 rows: botId={}, versionName={}\", botId, versionName);\n        throw new BusinessException(ResponseEnum.SYSTEM_ERROR);\n    }\n} catch (DataIntegrityViolationException e) {\n    log.error(\"MCP insert constraint violation: botId={}\", botId, e);\n    throw new BusinessException(ResponseEnum.PARAM_ERROR); // clearer client signal\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { mcpService.publishMcp(request, uid, spaceId); }\ncatch (BusinessException e) { if (e.getCode() == ResponseEnum.SYSTEM_ERROR) { alertOpsAndOfferRetry(); } else throw e; }","preventionTips":["Keep mcp_data schema in sync with the McpData entity across migrations.","Enforce column-size limits on serverName/description/content/icon at input time.","Monitor DB health; make publish retries idempotent (transaction rolls back on failure)."],"tags":["database","insert","publish","mcp"],"backgroundTag":"database-write-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}