{"record":{"id":"d4a634360a5dab46","repo":"iflytek/astron-agent","slug":"8100-workflow-version-add-failed","errorCode":"8100","errorMessage":"workflow.version.add.failed","messagePattern":"workflow\\.version\\.add\\.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":279,"sourceCode":"                    latestConfig.setConfig(workflowConfig.getConfig());\n                    workflowConfigMapper.updateById(workflowConfig);\n                } else {\n                    workflowConfig.setVersionNum(versionNum);\n                    workflowConfig.setId(null);\n                    workflowConfig.setName(createDto.getName());\n                    workflowConfigMapper.insert(workflowConfig);\n                }\n\n            }\n            workflowVersionMapper.insert(workflowVersion);\n\n            return ApiResult.success(new JSONObject()\n                    .fluentPut(\"workflowVersionId\", workflowVersion.getId())\n                    .fluentPut(\"workflowVersionName\", createDto.getName()));\n        } catch (BusinessException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_VERSION_ADD_FAILED);\n        }\n        //\n    }\n\n    private Workflow requireWorkflow(String flowId) {\n        Workflow workflow = workflowMapper.selectOne(Wrappers.lambdaQuery(Workflow.class)\n                .eq(Workflow::getFlowId, flowId)\n                .eq(Workflow::getDeleted, false));\n        if (workflow == null || Boolean.TRUE.equals(workflow.getDeleted())) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_NOT_EXIST);\n        }\n        return workflow;\n    }\n\n    /**\n     * Update isVersion flag for all versions of a specific flowId. Sets all versions' isVersion to 2\n     * (inactive) for the given flowId.\n     *","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/VersionService.java#L261-L297","documentation":"Generic wrapper error thrown when an unexpected exception occurs inside VersionService.createVersion while persisting a new workflow version. BusinessExceptions are re-thrown unchanged; anything else (DB errors, NPEs, sanitizer failures) is masked as WORKFLOW_VERSION_ADD_FAILED (code 8100). The real cause is only visible in server logs.","triggerScenarios":"createForSpace or createForBoundBotPublish calls createVersion and any non-BusinessException is thrown during version row insertion, JSON protocol processing, or the version-name computation within the try block.","commonSituations":"Database connection failure or lock timeout on workflow_version insert; null data/name in the DTO causing NPE; JSON serialization errors on workflow protocol data; unique constraint violations; missing transaction state.","solutions":["Check server logs at the ERROR level around the request time for the wrapped root cause (BusinessException is passed through, so anything hitting 8100 came from an unexpected exception)","Verify the database is reachable and workflow/workflow_version tables exist with the expected schema (flyway/migration state)","Validate that createDto (name, flowId, data) is non-null and non-empty before calling the API","Retry the version creation after fixing the underlying condition; if reproducible, add temporary logging or wrap the block to surface the original exception"],"exampleFix":"// before\n} catch (Exception e) {\n    throw new BusinessException(ResponseEnum.WORKFLOW_VERSION_ADD_FAILED);\n}\n// after\n} catch (Exception e) {\n    log.error(\"createVersion failed for flowId={}\", createDto.getFlowId(), e);\n    throw new BusinessException(ResponseEnum.WORKFLOW_VERSION_ADD_FAILED);\n}","handlingStrategy":"try-catch","validationCode":"if (dto == null || StrUtil.isBlank(dto.getName()) || StrUtil.isBlank(dto.getFlowId())) {\n    throw new IllegalArgumentException(\"name and flowId are required to create a workflow version\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ApiResult r = versionService.createVersion(dto);\n    if (r.getCode() == 8100) { /* check server logs / retry after validation */ }\n} catch (BusinessException e) {\n    log.error(\"version add failed: {}\", e.getMessage());\n}","preventionTips":["Validate DTO fields (name, flowId, data) non-null before calling","Monitor DB connectivity and migration state in the environment","Re-throw with the cause logged server-side for diagnosability","Keep workflow protocol JSON schema-valid before persisting"],"tags":["java","workflow","database"],"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"}