{"record":{"id":"4893a78c8e297b88","repo":"flowable/flowable-engine","slug":"invalid-body-was-supplied-4893a7","errorCode":null,"errorMessage":"Invalid body was supplied","messagePattern":"Invalid body was supplied","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableResource.java","lineNumber":121,"sourceCode":"        if (request instanceof MultipartHttpServletRequest) {\n            result = setBinaryVariable((MultipartHttpServletRequest) request, task, false);\n\n            if (!result.getName().equals(variableName)) {\n                throw new FlowableIllegalArgumentException(\"Variable name in the body should be equal to the name used in the requested URL.\");\n            }\n\n        } else {\n\n            RestVariable restVariable = null;\n\n            try {\n                restVariable = objectMapper.readValue(request.getInputStream(), RestVariable.class);\n            } catch (Exception e) {\n                throw new FlowableIllegalArgumentException(\"Error converting request body to RestVariable instance\", e);\n            }\n\n            if (restVariable == null) {\n                throw new FlowableException(\"Invalid body was supplied\");\n            }\n            if (!restVariable.getName().equals(variableName)) {\n                throw new FlowableIllegalArgumentException(\"Variable name in the body should be equal to the name used in the requested URL.\");\n            }\n\n            result = setSimpleVariable(restVariable, task, false);\n        }\n        return result;\n    }\n\n    @ApiOperation(value = \"Delete a variable on a task\", tags = { \"Task Variables\" }, nickname = \"deleteTaskInstanceVariable\", code = 204)\n    @ApiImplicitParams(@ApiImplicitParam(name = \"scope\", dataType = \"string\", value = \"Scope of variable to be returned. When local, only task-local variable value is returned. When global, only variable value from the task’s parent execution-hierarchy are returned. When the parameter is omitted, a local variable will be returned if it exists, otherwise a global variable.\", paramType = \"query\"))\n    @ApiResponses(value = {\n            @ApiResponse(code = 204, message = \"Indicates the task variable was found and has been deleted. Response-body is intentionally empty.\"),\n            @ApiResponse(code = 404, message = \"Indicates the requested task was not found or the task does not have a variable with the given name. Status message contains additional information about the error.\")\n    })\n    @DeleteMapping(value = \"/runtime/tasks/{taskId}/variables/{variableName}\")\n    @ResponseStatus(HttpStatus.NO_CONTENT)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableResource.java#L103-L139","documentation":"After successfully parsing the request body into a RestVariable, the update-variable endpoint checks that the resulting object is non-null. FlowableException('Invalid body was supplied') is thrown if Jackson parsed the stream but produced a null RestVariable (e.g. body was the literal JSON 'null' or effectively empty). It guards downstream code from dereferencing a null variable.","triggerScenarios":"PUT /runtime/tasks/{taskId}/variables/{variableName} (non-multipart) with a body that deserializes to null, most commonly the literal body 'null', or an empty/whitespace stream that Jackson maps to null.","commonSituations":"Client sends 'null' as body; template/serialization bug where variable payload is null; empty body with Content-Type: application/json passing the Jackson parse without exception.","solutions":["Send a complete JSON object with at least name, type and value fields.","Verify client-side serialization is not producing the string 'null'.","Add a client-side check that the payload object exists before issuing the PUT."],"exampleFix":"// before\ncurl -X PUT -H 'Content-Type: application/json' .../tasks/123/variables/name -d 'null'\n\n// after\ncurl -X PUT -H 'Content-Type: application/json' .../tasks/123/variables/name -d '{\"name\":\"name\",\"type\":\"string\",\"value\":\"John\"}'","handlingStrategy":"type-guard","validationCode":"if (payload == null || payload.name == null || payload.value === undefined) {\n  throw new Error('refusing to PUT null/empty variable body');\n}","typeGuard":"function isValidBody(v) {\n  return v != null && typeof v === 'object' && typeof v.name === 'string';\n}","tryCatchPattern":"try {\n  return await putVariable(url, body);\n} catch (e) {\n  if (String(e.message).includes('Invalid body was supplied')) console.error('body serialized to null:', body);\n  throw e;\n}","preventionTips":["Check the payload object for null before serializing the request body.","Never send the literal string 'null' or an empty body to a variable PUT.","Add a client-side assert that JSON.stringify(payload) !== 'null'."],"tags":["rest-api","flowable","validation","request-body"],"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-18T11:17:12.947Z"}