{"record":{"id":"3957ea5548be4e83","repo":"iflytek/astron-agent","slug":"8104-workflow-version-get-max-failed","errorCode":"8104","errorMessage":"workflow.version.get.max.failed","messagePattern":"workflow\\.version\\.get\\.max\\.failed","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/VersionService.java","lineNumber":776,"sourceCode":"                            .eq(WorkflowVersion::getFlowId, flowId)\n                            .eq(WorkflowVersion::getDeleted, false)\n                            .in(WorkflowVersion::getPublishResult,\n                                    WorkflowConst.PublishResult.SUCCESS,\n                                    WorkflowConst.PublishResult.LEGACY_SUCCESS,\n                                    WorkflowConst.PublishResult.LEGACY_SUCCESS_UPPER)\n                            .orderByDesc(WorkflowVersion::getCreatedTime)\n                            .last(\"LIMIT 1\"));\n\n            // Return result: if version exists return version name, if no version return \"Draft Version\"\n            String versionDisplay = (latestVersion != null) ? latestVersion.getName() : \"Draft Version\";\n            JSONObject workflowMaxVersion = new JSONObject().fluentPut(\"workflowMaxVersion\", versionDisplay)\n                    .fluentPut(\"versionNum\", (latestVersion != null) ? latestVersion.getVersionNum() : \"0\");\n            return ApiResult.success(workflowMaxVersion);\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            log.error(\"Query workflow maximum version number exception, botId: {}\", botId, e);\n            throw new BusinessException(ResponseEnum.WORKFLOW_VERSION_GET_MAX_FAILED);\n        }\n    }\n}\n","sourceCodeStart":758,"sourceCodeEnd":780,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/VersionService.java#L758-L780","documentation":"VersionService.getMaxVersion wraps any non-BusinessException failure of the max-version query into BusinessException(ResponseEnum.WORKFLOW_VERSION_GET_MAX_FAILED, code 8104). It is a catch-all indicating the latest-version lookup itself failed unexpectedly (as opposed to WORKFLOW_NOT_EXIST, which is rethrown unchanged).","triggerScenarios":"Integer.valueOf(botId) throws NumberFormatException for a non-numeric botId; a MyBatis-Plus/SQL exception while selecting the latest WorkflowVersion; SpaceInfoUtil.getSpaceId() failing (no space context); permission-check tool throwing a non-Business runtime exception.","commonSituations":"Frontend sends a string or empty botId; database connection pool exhausted; space ID missing from the request context (direct API call without the space header); schema drift between botId types.","solutions":["Inspect the server log line 'Query workflow maximum version number exception' for the root cause.","Send a numeric botId (e.g. \"42\", not \"abc\" or \"\").","Ensure the request carries valid space context so SpaceInfoUtil.getSpaceId() resolves.","Check DB health (connection pool, slow queries) if logs show SQL exceptions, then retry."],"exampleFix":"// before\ngetMaxVersion(request.getParameter(\"botId\")); // may be non-numeric -> 8104\n// after\nString botId = request.getParameter(\"botId\");\nif (botId == null || !botId.matches(\"\\\\d+\")) {\n    throw new BusinessException(ResponseEnum.PARAM_ERROR);\n}\ngetMaxVersion(botId);","handlingStrategy":"try-catch","validationCode":"if (botId == null || !botId.matches(\"\\\\d+\")) throw new BusinessException(ResponseEnum.PARAM_ERROR);","typeGuard":null,"tryCatchPattern":"try {\n    getMaxVersion(botId);\n} catch (BusinessException e) {\n    if (e.getCode() == 8104) {\n        log.error(\"max-version lookup failed for bot {}\", botId, e); // inspect root cause, retry or degrade\n    }\n}","preventionTips":["Always pass numeric botIds as strings of digits.","Ensure requests include the space context header so SpaceInfoUtil.getSpaceId() works.","Monitor DB pool health; the underlying SQL failure surfaces as 8104."],"tags":["workflow","database","unexpected-exception","bot"],"backgroundTag":"database-query-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"}