{"record":{"id":"8ef5b72514d143dc","repo":"iflytek/astron-agent","slug":"workflow-version-not-found-in-database-botid-versionname","errorCode":null,"errorMessage":"Workflow version not found in database: botId={}, versionName={}","messagePattern":"Workflow version not found in database: botId=(.+?), versionName=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java","lineNumber":260,"sourceCode":"    }\n\n    /**\n     * Get version system data from database\n     */\n    private JSONObject getVersionSysData(Integer botId, String versionName) {\n        try {\n            log.info(\"Getting version system data from database: botId={}, versionName={}\", botId, versionName);\n\n            // Query database for workflow version\n            LambdaQueryWrapper<WorkflowVersion> queryWrapper = new LambdaQueryWrapper<WorkflowVersion>()\n                    .eq(WorkflowVersion::getBotId, botId.toString())\n                    .eq(WorkflowVersion::getName, versionName)\n                    .last(\"LIMIT 1\");\n\n            WorkflowVersion workflowVersion = workflowVersionMapper.selectOne(queryWrapper);\n\n            if (workflowVersion == null) {\n                log.warn(\"Workflow version not found in database: botId={}, versionName={}\", botId, versionName);\n                return null;\n            }\n\n            String sysData = workflowVersion.getSysData();\n            if (sysData != null && !sysData.trim().isEmpty()) {\n                try {\n                    JSONObject versionData = JSON.parseObject(sysData);\n                    return versionData == null || versionData.isEmpty() ? null : versionData;\n                } catch (Exception e) {\n                    log.error(\n                            \"Failed to parse sysData JSON: botId={}, versionName={}, sysDataLength={}\",\n                            botId,\n                            versionName,\n                            sysData.length(),\n                            e);\n                    return null;\n                }\n            }","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/WorkflowReleaseServiceImpl.java#L242-L278","documentation":"getVersionSysData queries workflow_version by botId and exact version name (LIMIT 1). When no row matches, it logs a warning with both identifiers and returns null; the caller versionData then has no sysData to return. This indicates the requested published version does not exist for that bot.","triggerScenarios":"versionData(botId, versionName) is called with a versionName that has no matching row in the workflow_version table (typo, version never published, version deleted, wrong botId, or space mismatch filtering the row out).","commonSituations":"Client caches an old version name after the version was deleted/re-published; calling with a draft name that was never published; cross-space access where the bot belongs to another space; IDs passed as strings and truncated.","solutions":["Verify botId and versionName by listing existing versions (SELECT name FROM workflow_version WHERE bot_id=...) before calling","Confirm the version was actually published and not deleted or renamed","Check that the caller is operating in the correct space and the query isn't space-scoped away from the row","Handle the null return in versionData instead of letting it propagate as NPE downstream"],"exampleFix":"// before\nWorkflowVersion v = mapper.selectOne(qw.eq(botId).eq(name).last(\"LIMIT 1\"));\nreturn v.getSysData(); // NPE risk\n// after\nWorkflowVersion v = getVersionSysData(botId, versionName);\nif (v == null) { throw new EntityNotFoundException(\"version \" + versionName + \" not found for bot \" + botId); }","handlingStrategy":"validation","validationCode":"// verify the version exists before calling versionData\nLong count = workflowVersionMapper.selectCount(\n    new LambdaQueryWrapper<WorkflowVersion>()\n        .eq(WorkflowVersion::getBotId, botId)\n        .eq(WorkflowVersion::getName, versionName));\nif (count == 0) throw new IllegalArgumentException(\"Version \" + versionName + \" not found for bot \" + botId);","typeGuard":null,"tryCatchPattern":"String sysData = service.versionData(botId, versionName);\nif (sysData == null) {\n    throw new ResponseStatusException(NOT_FOUND, \"Workflow version \" + versionName + \" not found\");\n}","preventionTips":["Always list a bot's versions before referencing one by name","Treat version names as immutable once published; re-fetch after any publish/delete","Scope checks to the correct space to avoid silently missing rows","Never assume a cached versionName is still valid"],"tags":["java","mybatis","database","versioning"],"backgroundTag":"record-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}