{"record":{"id":"fbbd6aee74d04a97","repo":"flowable/flowable-engine","slug":"error-exporting-diagram-fbbd6a","errorCode":null,"errorMessage":"Error exporting diagram","messagePattern":"Error exporting diagram","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ProcessInstanceDiagramResource.java","lineNumber":81,"sourceCode":"    @GetMapping(value = \"/runtime/process-instances/{processInstanceId}/diagram\")\n    public ResponseEntity<byte[]> getProcessInstanceDiagram(@ApiParam(name = \"processInstanceId\") @PathVariable String processInstanceId, HttpServletResponse response) {\n        ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);\n\n        ProcessDefinition pde = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId());\n\n        if (pde != null && pde.hasGraphicalNotation()) {\n            BpmnModel bpmnModel = repositoryService.getBpmnModel(pde.getId());\n            ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();\n            InputStream resource = diagramGenerator.generateDiagram(bpmnModel, \"png\", runtimeService.getActiveActivityIds(processInstance.getId()), Collections.emptyList(),\n                    processEngineConfiguration.getActivityFontName(), processEngineConfiguration.getLabelFontName(),\n                    processEngineConfiguration.getAnnotationFontName(), processEngineConfiguration.getClassLoader(), 1.0,processEngineConfiguration.isDrawSequenceFlowNameWithNoLabelDI());\n\n            HttpHeaders responseHeaders = new HttpHeaders();\n            responseHeaders.set(\"Content-Type\", \"image/png\");\n            try {\n                return new ResponseEntity<>(IOUtils.toByteArray(resource), responseHeaders, HttpStatus.OK);\n            } catch (Exception e) {\n                throw new FlowableIllegalArgumentException(\"Error exporting diagram\", e);\n            }\n\n        } else {\n            throw new FlowableIllegalArgumentException(\"Process instance with id '\" + processInstance.getId() + \"' has no graphical notation defined.\");\n        }\n    }\n}\n","sourceCodeStart":63,"sourceCodeEnd":89,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/process/ProcessInstanceDiagramResource.java#L63-L89","documentation":"When a process instance diagram is requested, the REST layer converts the diagram resource stream to a PNG byte array. If any exception occurs while reading the resource (closed/broken stream, missing diagram resource, IO problem), getProcessInstanceDiagram wraps it in FlowableIllegalArgumentException('Error exporting diagram').","triggerScenarios":"GET /runtime/process-instances/{id}/diagram on an instance whose definition does have a graphical notation, but the resource stream cannot be read — e.g. the process-definition resource was undeployed/redeployed after the instance started, or an IO error while streaming. Thrown at ProcessInstanceDiagramResource.java:81.","commonSituations":"Definitions redeployed/undeployed while old instances are still running; database resource blob cleaned up; cluster with shared DB but missing deployment resources on one node; temporary DB connection issues during stream read.","solutions":["Check the process-definition resource still exists: GET /repository/deployments/{deploymentId}/resourcelist and verify the diagram/BPMN resource.","Redeploy the original BPMN (with diagram info) or restart the instance from a valid definition, then retry the diagram call.","Inspect the cause exception in server logs — usually an IO or DB problem reading ACT_GE_BYTEARRAY."],"exampleFix":"// before (client): assume diagram always available\ndef diagram = get(\"/runtime/process-instances/\" + id + \"/diagram\")\n// after: guard and redeploy/refresh definition if missing\nif (!definitionResourceExists(instance.getProcessDefinitionId())) {\n    redeployOriginalBpmn(processKey);\n}\ndef diagram = get(\"/runtime/process-instances/\" + id + \"/diagram\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    byte[] png = restClient.getDiagram(processInstanceId);\n} catch (HttpStatusCodeException e) {\n    if (e.getResponseBodyAsString().contains(\"Error exporting diagram\")) {\n        // inspect cause in server logs; verify deployment resource still exists, then retry\n    }\n}","preventionTips":["Avoid undeploying/cascading-deleting deployments with running instances.","Monitor DB connectivity; diagram export reads the resource blob.","Cache diagram images to reduce repeated stream reads."],"tags":["rest-api","diagram","io-error","java"],"backgroundTag":"http-request-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}