{"record":{"id":"91b7097c9b8287dd","repo":"flowable/flowable-engine","slug":"could-not-process-multipart-content","errorCode":null,"errorMessage":"Could not process multipart content","messagePattern":"Could not process multipart content","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java","lineNumber":385,"sourceCode":"                setVariable(instanceId, variableName, value, scope, isNew, async, variableInterceptor);\n                stream.close();\n            } else {\n                throw new FlowableContentNotSupportedException(\"Serialized objects are not allowed\");\n            }\n\n            RestVariable restVariable = null;\n            \n            if (!async) {\n                restVariable = getVariableFromRequestWithoutAccessCheck(instanceId, variableName, responseVariableType, false);\n                \n                // We are setting the scope because the fetched variable does not have it\n                restVariable.setVariableScope(scope);\n            }\n            \n            return restVariable;\n            \n        } catch (IOException ioe) {\n            throw new FlowableIllegalArgumentException(\"Could not process multipart content\", ioe);\n            \n        } catch (ClassNotFoundException ioe) {\n            throw new FlowableContentNotSupportedException(\n                    \"The provided body contains a serialized object for which the class was not found: \" + ioe.getMessage());\n        }\n    }\n\n    protected void setVariable(String instanceId, String name, Object value, RestVariableScope scope, boolean isNew, boolean async, VariableInterceptor variableInterceptor) {\n        if (isNew) {\n            variableInterceptor.createVariables(Collections.singletonMap(name, value));\n        } else {\n            variableInterceptor.updateVariables(Collections.singletonMap(name, value));\n        }\n\n        if (RestVariableScope.LOCAL == scope) {\n            //the guard is only added here, because this whole block is new\n            if (isNew && runtimeService.hasLocalVariable(instanceId, name)) {\n                throw new FlowableConflictException(\"Local variable '\" + name + \"' is already present on plan item instance '\" + instanceId + \"'.\");","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java#L367-L403","documentation":"setBinaryVariable reads the multipart request body via the servlet/parts API; an IOException while consuming that stream (broken upload, unreadable part, container I/O failure) is wrapped in this FlowableIllegalArgumentException. It signals the REST layer could not read or process the multipart content it received, before any variable is written.","triggerScenarios":"POST/PUT of a binary variable where the multipart stream is truncated or unreadable, the part cannot be accessed (e.g. temp file deleted), or an IOException is thrown by file.getInputStream()/readObject while reading the uploaded part.","commonSituations":"Network interruptions during large uploads, servlet container temp-directory issues (disk full, cleanup daemon deleting parts), proxy/gateway truncating request bodies, timeouts on slow uploads.","solutions":["Retry the upload, ensuring the request completes fully without interruption","Check the servlet container temp directory (disk space, permissions) for multipart storage","Increase client/server timeouts and any max-size limits for the upload","Inspect the wrapped IOException cause for the root I/O problem (connection reset, disk error, etc.)"],"exampleFix":"// before\nFile diff suppressed: request sent with Content-Length mismatch / truncated body\n// after\n// verify content-length and stream the file fully; catch FlowableIllegalArgumentException\ntry {\n    restClient.post().uri(variablesUrl).body(multipartData).retrieve().toBodilessEntity();\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"multipart upload failed: {}\", e.getCause(), e);\n}","handlingStrategy":"try-catch","validationCode":"long contentLength = part.getSize();\nif (contentLength <= 0) throw new IllegalStateException(\"Empty multipart part; check upload completed\");","typeGuard":"null","tryCatchPattern":"try {\n    postBinaryVariable(name, file);\n} catch (HttpServerErrorException e) {\n    if (e.getResponseBodyAsString().contains(\"Could not process multipart content\")) {\n        retryWithBackoff(() -> postBinaryVariable(name, file));\n    }\n}","preventionTips":["Ensure uploads complete fully (stable network, adequate timeouts)","Verify servlet container temp dir has space and correct permissions","Check proxy/gateway does not truncate large request bodies"],"tags":["rest","multipart","io","upload"],"backgroundTag":"http-request-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}