{"record":{"id":"1a237e4096911a35","repo":"iflytek/astron-agent","slug":"parameter-error-1a237e","errorCode":"PARAMETER_ERROR","errorMessage":"PARAMETER_ERROR","messagePattern":"PARAMETER_ERROR","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java","lineNumber":130,"sourceCode":"        // Check if response is successful\n        if (botInfoDto == null) {\n            throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);\n        }\n        // Copy a new workflow for the assistant\n        JSONObject res = maasUtil.copyWorkFlow(maasDuplicate.getMaasId(), request, BotVersionEnum.WORKFLOW.getVersion(), Long.valueOf(botInfoDto.getBotId()), null);\n        if (Objects.isNull(res) || res.isEmpty()) {\n            throw new BusinessException(ResponseEnum.CREATE_BOT_FAILED);\n        }\n        Integer botId = botInfoDto.getBotId();\n        botService.addMaasInfo(uid, res, botId, spaceId);\n        botInfoDto.setFlowId(res.getJSONObject(\"data\").getLong(\"id\"));\n        return botInfoDto;\n    }\n\n    private BotInfoDto createFromExportedTemplate(String uid, MaasDuplicate maasDuplicate, HttpServletRequest request) {\n        Long templateId = maasDuplicate.getTemplateId();\n        if (templateId == null) {\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n\n        ExportedWorkflowTemplate template = loadAvailableTemplate(uid, templateId);\n        if (template == null || StringUtils.isBlank(template.getSnapshotYaml())) {\n            log.warn(\"Create workflow from exported template failed, templateId={}, uid={}, spaceId={}, templateFound={}, snapshotBlank={}\",\n                    templateId,\n                    uid,\n                    SpaceInfoUtil.getSpaceId(),\n                    template != null,\n                    template == null || StringUtils.isBlank(template.getSnapshotYaml()));\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);\n        }\n\n        ApiResult<?> importResult = workflowExportService.importWorkflowFromYaml(\n                new ByteArrayInputStream(template.getSnapshotYaml().getBytes(StandardCharsets.UTF_8)),\n                request);\n        if (importResult.code() != 0 || !(importResult.data() instanceof Workflow importedWorkflow)) {\n            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java#L112-L148","documentation":"Thrown at the top of createFromExportedTemplate when maasDuplicate.getTemplateId() is null. Creating a workflow from an exported template requires an explicit templateId; without it the request is malformed and rejected with PARAMETER_ERROR before any lookup.","triggerScenarios":"Calling createFromTemplate with a request whose type routes to the exported-template path but whose templateId field is missing/null (e.g. client omitted templateId in the body).","commonSituations":"Frontend not populating templateId for exported-template creation, API consumers copying payloads between official-template and exported-template flows, or DTO deserialization silently dropping the field due to a type mismatch.","solutions":["Ensure the request body includes a non-null templateId when creating from an exported template","Check the frontend form/API client actually sends templateId (inspect the outgoing JSON)","Verify MaasDuplicate DTO field types match the incoming JSON so templateId is not dropped during deserialization","Validate templateId in the controller layer and return a clear 400 message before reaching the service"],"exampleFix":"// before\nMaasDuplicate maasDuplicate = ...; // templateId never set\nbotMaasService.createFromTemplate(uid, maasDuplicate, request);\n// after\nif (maasDuplicate.getTemplateId() == null) {\n    throw new IllegalArgumentException(\"templateId is required when creating from an exported template\");\n}\nbotMaasService.createFromTemplate(uid, maasDuplicate, request);","handlingStrategy":"validation","validationCode":"if (req == null || req.getTemplateId() == null) {\n    return ApiResult.fail(\"templateId is required for exported-template creation\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    botMaasService.createFromTemplate(uid, req, httpRequest);\n} catch (BusinessException e) {\n    if (ResponseEnum.PARAMETER_ERROR.getCode().equals(e.getCode())) {\n        // return 400 with 'templateId required'\n    }\n    throw e;\n}","preventionTips":["Annotate DTO fields with @NotNull and enable @Valid","Verify frontend always sends templateId on this flow","Check JSON field-name alignment with the DTO","Cover both template-creation paths with contract tests"],"tags":["validation","request-parameters","template"],"backgroundTag":"missing-required-argument","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"}