{"record":{"id":"f5fbb1d84476ff3e","repo":"iflytek/astron-agent","slug":"8113-workflow-export-failed","errorCode":"8113","errorMessage":"workflow.export.failed","messagePattern":"workflow\\.export\\.failed","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/workflow/WorkflowController.java","lineNumber":464,"sourceCode":"    @GetMapping(\"/get-workflow-prompt-status\")\n    public Object getWorkflowPromptStatus(@RequestParam @NotNull Long id) {\n        return workflowService.getWorkflowPromptStatus(id);\n    }\n\n    // ---------------------- Export/Import YAML ----------------------\n\n    /**\n     * Export workflow as YAML.\n     *\n     * <p>\n     * Note: Add filename to avoid browser downloading as unnamed file.\n     */\n    @GetMapping(\"/export/{id}\")\n    public void exportYaml(@PathVariable @NotNull Long id, HttpServletResponse response) {\n        final Workflow entity = workflowService.getById(id);\n        try {\n            if (entity == null || StringUtils.isEmpty(entity.getData())) {\n                throw new BusinessException(ResponseEnum.WORKFLOW_EXPORT_FAILED);\n            }\n            // Construct download filename: workflow-{id}.yaml\n            final String filename =\n                    URLEncoder.encode(\"workflow-\" + id + \".yaml\", StandardCharsets.UTF_8).replaceAll(\"\\\\+\", \"%20\");\n\n            response.setContentType(\"application/octet-stream\");\n            response.setCharacterEncoding(StandardCharsets.UTF_8.name());\n            response.setHeader(\"Content-Disposition\", \"attachment; filename*=UTF-8''\" + filename);\n\n            workflowExportService.exportWorkflowDataAsYaml(entity, response.getOutputStream());\n            response.flushBuffer();\n        } catch (BusinessException e) {\n            log.error(\"export yaml business error, id={}\", id, e);\n            throw e;\n        } catch (Exception e) {\n            log.error(\"export yaml unexpected error, id={}\", id, e);\n            throw new BusinessException(ResponseEnum.WORKFLOW_EXPORT_FAILED);\n        }","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/workflow/WorkflowController.java#L446-L482","documentation":"exportYaml() exports a workflow as YAML. Before streaming the file it loads the workflow entity; if the id does not exist or the entity's data column is empty, it throws BusinessException(ResponseEnum.WORKFLOW_EXPORT_FAILED) (code 8113, message key workflow.export.failed). This is a pre-flight guard preventing an empty download.","triggerScenarios":"GET /workflow/export/{id} where the id has no matching workflow row, or the row exists but its data field is null/blank.","commonSituations":"Stale frontend link after the workflow was deleted; exporting a workflow that was created but never saved with DSL data; wrong id passed from another environment/database; soft-deleted record still referenced in the UI.","solutions":["Verify the workflow id exists via GET /workflow detail or the workflow list before calling export.","Re-save the workflow so its data (DSL) field is populated, then retry the export.","If the workflow was deleted, recreate it or restore it from backup; export cannot proceed without data.","Client-side: catch the 8113 error and prompt the user that the workflow is missing or empty instead of downloading."],"exampleFix":"// before\nconst blob = await fetch(`/workflow/export/${id}`) // id may be stale\n\n// after\nconst wf = await fetch(`/workflow/detail/${id}`).then(r => r.json())\nif (!wf?.data) throw new Error('Workflow has no DSL data to export')\nconst blob = await fetch(`/workflow/export/${id}`)","handlingStrategy":"validation","validationCode":"const wf = await api.get(`/workflow/detail/${id}`).catch(() => null);\nif (!wf || !wf.data) {\n  throw new Error(`Workflow ${id} missing or has no DSL data; export aborted`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await downloadYaml(id);\n} catch (e) {\n  if (e.code === 8113) notify('Workflow not found or empty — cannot export');\n  else throw e;\n}","preventionTips":["Refresh the workflow list after deletions so stale export links disappear.","Check the workflow has saved DSL data before enabling the export button in the UI.","Pass ids from a freshly fetched list rather than cached/bookmarked URLs."],"tags":["export","workflow","yaml","entity-not-found","java"],"backgroundTag":"entity-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"}