{"record":{"id":"8796454050577b41","repo":"flowable/flowable-engine","slug":"error-creating-attachment-data","errorCode":null,"errorMessage":"Error creating attachment data","messagePattern":"Error creating attachment data","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskAttachmentContentResource.java","lineNumber":86,"sourceCode":"        HttpHeaders responseHeaders = new HttpHeaders();\n        MediaType mediaType = null;\n        if (attachment.getType() != null) {\n            try {\n                mediaType = MediaType.valueOf(attachment.getType());\n                responseHeaders.set(\"Content-Type\", attachment.getType());\n            } catch (Exception e) {\n                // ignore if unknown media type\n            }\n        }\n\n        if (mediaType == null) {\n            responseHeaders.set(\"Content-Type\", \"application/octet-stream\");\n        }\n\n        try {\n            return new ResponseEntity<>(IOUtils.toByteArray(attachmentStream), responseHeaders, HttpStatus.OK);\n        } catch (Exception e) {\n            throw new FlowableException(\"Error creating attachment data\", e);\n        }\n    }\n}\n","sourceCodeStart":68,"sourceCodeEnd":90,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskAttachmentContentResource.java#L68-L90","documentation":"Wrapping FlowableException raised when converting the attachment's InputStream to a byte array (IOUtils.toByteArray) fails, or building the response entity otherwise errors. The original exception is preserved as the cause.","triggerScenarios":"GET .../attachments/{attachmentId}/content where reading the content stream fails mid-read — storage backend IO error, stream closed early, network failure to a remote content store, or OOM on very large attachments.","commonSituations":"Filesystem content store path missing or permissions changed; DB blob column unreadable; remote content store (e.g. S3) unreachable; attachments larger than available memory since the whole stream is buffered in memory.","solutions":["Check the cause exception for the underlying IO/storage error","Verify the content store location, permissions, and connectivity","For large attachments, increase memory or stream content instead of buffering","Confirm the content record is not corrupted/truncated"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const att = await api.getTaskAttachment(taskId, attachmentId);\nif (att && att.size > 50 * 1024 * 1024) console.warn('Large attachment; consider streaming');","typeGuard":null,"tryCatchPattern":"try { return await api.getAttachmentContent(taskId, attachmentId); } catch (e) { log.error('Attachment download failed', e); throw new Error('Attachment content could not be read; check content store'); }","preventionTips":["Keep the content store (filesystem/DB) healthy and backed up","Avoid loading very large attachments fully into memory","Re-upload the attachment if content corruption is suspected"],"tags":["rest","io","attachments","content-store"],"backgroundTag":"file-read-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}