{"record":{"id":"e7c7845047f2b78f","repo":"iflytek/astron-agent","slug":"exported-workflow-template-unavailable-templateid-uid","errorCode":null,"errorMessage":"Exported workflow template unavailable, templateId={}, uid={}, templateFound={}, isDelete={}","messagePattern":"Exported workflow template unavailable, templateId=(.+?), uid=(.+?), templateFound=(.+?), isDelete=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/workflow/impl/BotMaasServiceImpl.java","lineNumber":166,"sourceCode":"            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_FAILED);\n        }\n\n        JSONObject ext = JSONObject.parseObject(importedWorkflow.getExt());\n        BotInfoDto botInfoDto = new BotInfoDto();\n        botInfoDto.setBotId(ext == null ? null : ext.getInteger(\"botId\"));\n        botInfoDto.setBotName(importedWorkflow.getName());\n        botInfoDto.setBotDesc(importedWorkflow.getDescription());\n        botInfoDto.setAvatar(importedWorkflow.getAvatarIcon());\n        botInfoDto.setVersion(BotVersionEnum.WORKFLOW.getVersion());\n        botInfoDto.setFlowId(importedWorkflow.getId());\n        botInfoDto.setMaasId(importedWorkflow.getId());\n        return botInfoDto;\n    }\n\n    private ExportedWorkflowTemplate loadAvailableTemplate(String uid, Long templateId) {\n        ExportedWorkflowTemplate template = exportedWorkflowTemplateMapper.selectById(templateId);\n        if (template == null || !Objects.equals(template.getIsDelete(), (byte) 0)) {\n            log.warn(\"Exported workflow template unavailable, templateId={}, uid={}, templateFound={}, isDelete={}\",\n                    templateId,\n                    uid,\n                    template != null,\n                    template == null ? null : template.getIsDelete());\n            return null;\n        }\n\n        if (StringUtils.isNotBlank(template.getSnapshotYaml())) {\n            return template;\n        }\n\n        if (template.getSourceWorkflowId() == null) {\n            return template;\n        }\n\n        Workflow sourceWorkflow = workflowService.getById(template.getSourceWorkflowId());\n        if (sourceWorkflow == null) {\n            return template;","sourceCodeStart":148,"sourceCodeEnd":184,"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#L148-L184","documentation":"WARN from loadAvailableTemplate: the ExportedWorkflowTemplate lookup by templateId returned null or the row is soft-deleted (isDelete != 0). loadAvailableTemplate returns null, which callers translate into BOT_NOT_EXIST exceptions.","triggerScenarios":"selectById misses (wrong/foreign templateId), or template.getIsDelete() is 1 because it was deleted via deleteTemplate.","commonSituations":"Using a templateId from another space/tenant; referencing a template deleted by its creator; hardcoded templateIds in tests/config after data cleanup.","solutions":["Verify templateId exists and isDelete=0 before use (e.g. SELECT is_delete FROM exported_workflow_template WHERE id=?).","Refresh the template list on the client so deleted templates are no longer referenced.","If templates should be space-visible, include the space/uid filter in lookup logic and surface a clear not-found message."],"exampleFix":"// before\nLong templateId = dto.getTemplateId(); // possibly stale\nservice.createFromTemplate(uid, templateId);\n// after\nExportedWorkflowTemplate t = exportedWorkflowTemplateMapper.selectById(dto.getTemplateId());\nif (t == null || t.getIsDelete() != 0) { throw new BusinessException(ResponseEnum.BOT_NOT_EXIST); }","handlingStrategy":"validation","validationCode":"boolean templateAvailable = java.util.Optional.ofNullable(exportedWorkflowTemplateMapper.selectById(id))\n    .map(t -> Objects.equals(t.getIsDelete(), (byte) 0)).orElse(false);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check isDelete=0 before referencing a templateId.","Never hardcode templateIds in configs/tests without existence checks.","Filter deleted templates out of all client-facing lists."],"tags":["workflow","template","soft-delete","lookup"],"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-15T23:17:13.987Z"}