{"record":{"id":"fc39afbcfdd1dcca","repo":"flowable/flowable-engine","slug":"error-creating-attachment-response","errorCode":null,"errorMessage":"Error creating attachment response","messagePattern":"Error creating attachment response","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskAttachmentCollectionResource.java","lineNumber":180,"sourceCode":"        }\n\n        if (request.getFileMap().size() == 0) {\n            throw new FlowableIllegalArgumentException(\"Attachment content is required.\");\n        }\n\n        MultipartFile file = request.getFileMap().values().iterator().next();\n\n        if (file == null) {\n            throw new FlowableIllegalArgumentException(\"Attachment content is required.\");\n        }\n\n        try {\n            Attachment createdAttachment = taskService.createAttachment(type, task.getId(), task.getProcessInstanceId(), name, description, file.getInputStream());\n\n            return restResponseFactory.createAttachmentResponse(createdAttachment);\n\n        } catch (Exception e) {\n            throw new FlowableException(\"Error creating attachment response\", e);\n        }\n    }\n}\n","sourceCodeStart":162,"sourceCodeEnd":184,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskAttachmentCollectionResource.java#L162-L184","documentation":"Wrapping FlowableException raised when anything in the binary-attachment creation path fails: reading the uploaded file's InputStream, taskService.createAttachment persisting it, or building the REST response. It is a checked catch-all that preserves the original cause.","triggerScenarios":"POST creating a binary task attachment where file.getInputStream() throws (part already consumed/corrupt), the underlying persistence fails, or restResponseFactory.createAttachmentResponse throws.","commonSituations":"Uploaded part stream already consumed by an earlier filter; database connectivity problems; content store (filesystem/DB blob) misconfiguration; extremely large uploads exceeding storage limits.","solutions":["Inspect the wrapped cause exception in the response/log for the real failure","Verify database and content-store connectivity and configuration","Ensure no filter consumes the multipart stream before the resource reads it","Retry with a smaller file to rule out size/storage limits"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const resp = await api.createBinaryAttachment(taskId, formData); return resp; } catch (e) { log.error('Attachment creation failed: ' + (e.cause || e.message)); throw e; }","preventionTips":["Always inspect the cause of this wrapper for the real error","Keep multipart streams unread before the upload call","Monitor DB/content-store health; most causes are storage-side","Avoid extremely large uploads; buffer size can trigger IO failures"],"tags":["rest","attachments","io","wrapped-exception"],"backgroundTag":"api-error-response","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"}