{"record":{"id":"8d3cd109a4ab0d93","repo":"iflytek/astron-agent","slug":"repair-exported-workflow-template-snapshot-failed-templateid","errorCode":null,"errorMessage":"Repair exported workflow template snapshot failed, templateId={}","messagePattern":"Repair exported workflow template snapshot failed, templateId=(.+?)","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":194,"sourceCode":"        }\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;\n        }\n\n        try {\n            template.setSnapshotYaml(exportWorkflowSnapshot(sourceWorkflow));\n            exportedWorkflowTemplateMapper.updateById(template);\n            log.info(\"Repaired exported workflow template snapshot, templateId={}, sourceWorkflowId={}\",\n                    templateId,\n                    template.getSourceWorkflowId());\n        } catch (Exception e) {\n            log.warn(\"Repair exported workflow template snapshot failed, templateId={}\", templateId, e);\n        }\n        return template;\n    }\n\n    @Override\n    public Integer maasCopySynchronize(CloneSynchronize synchronize) {\n        log.info(\"------ Astron workflow copy synchronization: {}\", JSONObject.toJSONString(synchronize));\n        String uid = synchronize.getUid();\n        Long originId = synchronize.getOriginId();\n        Long maasId = synchronize.getCurrentId();\n        String flowId = synchronize.getFlowId();\n        Long spaceId = synchronize.getSpaceId();\n        UserLangChainInfo userLangChainInfo = userLangChainDataService.selectByMaasId(originId);\n        if (Objects.isNull(userLangChainInfo)) {\n            log.info(\"----- Xinghuo did not find Astron workflow: {}\", JSONObject.toJSONString(synchronize));\n            throw new BusinessException(ResponseEnum.BOT_NOT_EXIST);\n        }\n        Integer botId = userLangChainInfo.getBotId();","sourceCodeStart":176,"sourceCodeEnd":212,"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#L176-L212","documentation":"WARN from loadAvailableTemplate's repair path: when a template's snapshotYaml is blank, the code tries to regenerate it from the source workflow and persist it; any exception during that repair is caught, logged, and swallowed — the possibly-blank template is still returned (leading to BOT_NOT_EXIST downstream).","triggerScenarios":"Template references a sourceWorkflowId that is missing/corrupt, or exportWorkflowSnapshot/updateById throws (DB error, serialization error) during the lazy repair.","commonSituations":"Source workflow deleted or migrated after template export; database connectivity issues during repair; YAML serialization failure for legacy workflow definitions.","solutions":["Check the attached stack trace for the root cause (usually missing source workflow or DB error) and restore/regenerate the snapshot.","Re-export the template from an existing workflow to replace the broken one.","Consider rethrowing or returning null on repair failure instead of returning a template with a blank snapshot, so callers fail fast with a clear reason."],"exampleFix":"// before\ncatch (Exception e) {\n    log.warn(\"Repair exported workflow template snapshot failed, templateId={}\", templateId, e);\n}\nreturn template;\n// after\ncatch (Exception e) {\n    log.warn(\"Repair exported workflow template snapshot failed, templateId={}\", templateId, e);\n    return null; // let callers surface BOT_NOT_EXIST with a clear cause\n}","handlingStrategy":"try-catch","validationCode":"boolean snapshotReady = template != null && StringUtils.isNotBlank(template.getSnapshotYaml());","typeGuard":null,"tryCatchPattern":"try {\n    createFromTemplate(uid, templateId);\n} catch (BusinessException e) {\n    log.error(\"Template {} unusable, snapshot repair likely failed\", templateId, e);\n    reExportTemplate(sourceWorkflowId);\n}","preventionTips":["Keep source workflows intact or archive their definitions before template export.","Monitor repair-failure logs and alert on recurrence.","Fail fast: treat repair failure as a hard error rather than returning a broken template."],"tags":["workflow","template","snapshot-repair","data-repair"],"backgroundTag":"file-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"}