{"record":{"id":"0859fada905bab55","repo":"flowable/flowable-engine","slug":"attachment-name-is-required","errorCode":null,"errorMessage":"Attachment name is required.","messagePattern":"Attachment name is required\\.","errorType":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskAttachmentCollectionResource.java","lineNumber":129,"sourceCode":"\n            } catch (Exception e) {\n                throw new FlowableIllegalArgumentException(\"Failed to serialize to a AttachmentRequest instance\", e);\n            }\n\n            if (attachmentRequest == null) {\n                throw new FlowableIllegalArgumentException(\"AttachmentRequest properties not found in request\");\n            }\n\n            result = createSimpleAttachment(attachmentRequest, task);\n        }\n\n        return result;\n    }\n\n    protected AttachmentResponse createSimpleAttachment(AttachmentRequest attachmentRequest, Task task) {\n\n        if (attachmentRequest.getName() == null) {\n            throw new FlowableIllegalArgumentException(\"Attachment name is required.\");\n        }\n\n        Attachment createdAttachment = taskService.createAttachment(attachmentRequest.getType(), task.getId(), task.getProcessInstanceId(), attachmentRequest.getName(),\n                attachmentRequest.getDescription(), attachmentRequest.getExternalUrl());\n\n        return restResponseFactory.createAttachmentResponse(createdAttachment);\n    }\n\n    protected AttachmentResponse createBinaryAttachment(MultipartHttpServletRequest request, Task task) {\n\n        String name = null;\n        String description = null;\n        String type = null;\n\n        Map<String, String[]> paramMap = request.getParameterMap();\n        for (String parameterName : paramMap.keySet()) {\n            if (paramMap.get(parameterName).length > 0) {\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskAttachmentCollectionResource.java#L111-L147","documentation":"createSimpleAttachment (JSON path of task attachment creation) requires the AttachmentRequest to carry a name. If attachmentRequest.getName() is null, Flowable throws FlowableIllegalArgumentException(\"Attachment name is required.\") because taskService.createAttachment needs a non-null attachment name.","triggerScenarios":"POST /runtime/tasks/{taskId}/attachments with a JSON body that omits the \"name\" field or sets it to null, e.g. {\"description\":\"only desc\"}.","commonSituations":"Clients assuming only externalUrl or description is needed, optional-field serializers dropping null/empty name keys, API clients built from outdated docs.","solutions":["Always include a non-null \"name\" in the attachment JSON body.","In client code, default the name from the file name or URL when not provided.","Validate required fields (name) before calling the API.","If name genuinely is optional for your use case, use the binary attachment endpoint which takes the name from multipart parameters."],"exampleFix":"// before\n{\"description\":\"Design doc\"}\n\n// after\n{\"name\":\"design-doc.pdf\",\"description\":\"Design doc\"}","handlingStrategy":"validation","validationCode":"if (typeof attachment.name !== 'string' || attachment.name.trim() === '') {\n  throw new Error('Attachment name is required before calling the API');\n}","typeGuard":"function hasName(a) { return a != null && typeof a.name === 'string' && a.name.length > 0; }","tryCatchPattern":"try {\n  await api.post(`/tasks/${taskId}/attachments`, attachment);\n} catch (e) {\n  if (/Attachment name is required/.test(e.response?.data?.message || '')) {\n    attachment.name = fallbackName; // e.g. derived from externalUrl\n  }\n}","preventionTips":["Always populate the name field, defaulting from filename/URL.","Strip null/empty fields carefully: never strip required ones.","Add schema validation (name required) in API client wrappers."],"tags":["rest-api","validation","attachments","flowable"],"backgroundTag":"missing-required-argument","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"}