flowable/flowable-engine · error · FlowableIllegalArgumentException

Multipart request with file content is required

Error message

Multipart request with file content is required

What it means

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.

Source

Thrown at modules/flowable-rest/src/main/java/org/flowable/rest/service/api/repository/ModelSourceResource.java:88

    @ApiImplicitParams({
            @ApiImplicitParam(name = "file", dataType = "file", paramType = "form", required = true)
    })
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Indicates the model was found and the source has been updated."),
            @ApiResponse(code = 404, message = "Indicates the requested model was not found.")
    })
    @PutMapping(value = "/repository/models/{modelId}/source", consumes = "multipart/form-data")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void setModelSource(@ApiParam(name = "modelId") @PathVariable String modelId, HttpServletRequest request) {
        Model model = getModelFromRequest(modelId);
        if (!(request instanceof MultipartHttpServletRequest)) {
                throw new FlowableIllegalArgumentException("Multipart request is required");
        }

        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

        if (multipartRequest.getFileMap().size() == 0) {
            throw new FlowableIllegalArgumentException("Multipart request with file content is required");
        }

        MultipartFile file = multipartRequest.getFileMap().values().iterator().next();

        try {
            repositoryService.addModelEditorSource(model.getId(), file.getBytes());
        } catch (Exception e) {
            throw new FlowableException("Error adding model editor source extra", e);
        }
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Send multipart/form-data with a 'file' part containing the model XML/source
  2. Check the client's content type header

Example fix

// before
curl -X PUT -F 'filename=src.xml' .../models/id/source
// after
curl -X PUT -F 'file=@src.xml' .../models/id/source
Defensive patterns

Strategy: validation

Validate before calling

if (file == null || !file.canRead()) throw new IllegalArgumentException("provide a readable file part for the model source");

Try / catch

try { setModelSource(modelId, request); } catch (FlowableIllegalArgumentException e) { log.error("no file part in multipart body", e); }

Prevention

When it happens

Trigger: multipart/form-data request containing only non-file fields, empty parts, or a malformed body so multipartRequest.getFileMap() is empty.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/d628892378a9e724. Report an issue: GitHub.