{"record":{"id":"d628892378a9e724","repo":"flowable/flowable-engine","slug":"multipart-request-with-file-content-is-required-d62889","errorCode":null,"errorMessage":"Multipart request with file content is required","messagePattern":"Multipart request with file content is required","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/repository/ModelSourceResource.java","lineNumber":88,"sourceCode":"    @ApiImplicitParams({\n            @ApiImplicitParam(name = \"file\", dataType = \"file\", paramType = \"form\", required = true)\n    })\n    @ApiResponses(value = {\n            @ApiResponse(code = 204, message = \"Indicates the model was found and the source has been updated.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested model was not found.\")\n    })\n    @PutMapping(value = \"/repository/models/{modelId}/source\", consumes = \"multipart/form-data\")\n    @ResponseStatus(HttpStatus.NO_CONTENT)\n    public void setModelSource(@ApiParam(name = \"modelId\") @PathVariable String modelId, HttpServletRequest request) {\n        Model model = getModelFromRequest(modelId);\n        if (!(request instanceof MultipartHttpServletRequest)) {\n                throw new FlowableIllegalArgumentException(\"Multipart request is required\");\n        }\n\n        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;\n\n        if (multipartRequest.getFileMap().size() == 0) {\n            throw new FlowableIllegalArgumentException(\"Multipart request with file content is required\");\n        }\n\n        MultipartFile file = multipartRequest.getFileMap().values().iterator().next();\n\n        try {\n            repositoryService.addModelEditorSource(model.getId(), file.getBytes());\n        } catch (Exception e) {\n            throw new FlowableException(\"Error adding model editor source extra\", e);\n        }\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":100,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/repository/ModelSourceResource.java#L70-L100","documentation":"Request validation in ModelSourceResource.setModelSource: the PUT was multipart but contained no file part, so there is no source content to store on the model.","triggerScenarios":"multipart/form-data request containing only non-file fields, empty parts, or a malformed body so multipartRequest.getFileMap() is empty.","commonSituations":"Automation scripts that build the form without the file field; file attachment silently dropped by a client library; wrong field name treated as text part.","solutions":["Send multipart/form-data with a 'file' part containing the model XML/source","Check the client's content type header"],"exampleFix":"// before\ncurl -X PUT -F 'filename=src.xml' .../models/id/source\n// after\ncurl -X PUT -F 'file=@src.xml' .../models/id/source","handlingStrategy":"validation","validationCode":"if (file == null || !file.canRead()) throw new IllegalArgumentException(\"provide a readable file part for the model source\");","typeGuard":null,"tryCatchPattern":"try { setModelSource(modelId, request); } catch (FlowableIllegalArgumentException e) { log.error(\"no file part in multipart body\", e); }","preventionTips":["Attach the actual file (file=@...) every time","Validate file existence before the upload step","Test multipart payloads with a proxy or curl -v"],"tags":["flowable","rest","multipart","validation"],"backgroundTag":"empty-required-field","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}