{"record":{"id":"8440aa00493ce53d","repo":"flowable/flowable-engine","slug":"error-converting-request-body-to-restvariable-inst-8440aa","errorCode":null,"errorMessage":"Error converting request body to RestVariable instance","messagePattern":"Error converting request body to RestVariable instance","errorType":"http","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskVariableResource.java","lineNumber":117,"sourceCode":"\n        Task task = getTaskFromRequestWithoutAccessCheck(taskId);\n\n        RestVariable result = null;\n        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.\"),","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/task/TaskVariableResource.java#L99-L135","documentation":"FlowableIllegalArgumentException thrown by updateVariable when the request body cannot be deserialized by Jackson into a RestVariable object. The body must be valid JSON matching the RestVariable schema (at least {\"name\": ...}). The parse exception is preserved as the cause.","triggerScenarios":"PUT /cmmn-runtime/tasks/{taskId}/variables/{name} with a non-JSON content type, malformed JSON, or a JSON value that is not an object (e.g. a bare string or number).","commonSituations":"Sending raw values (\"42\") instead of a RestVariable object; wrong Content-Type header causing the raw stream to be parsed; truncated bodies from proxy misconfiguration.","solutions":["Send a JSON object body like {\"name\":\"x\",\"value\":42,\"type\":\"integer\"}","Set Content-Type: application/json","Check server logs for the nested Jackson cause to find the exact parse error","Validate the JSON body with a linter before sending"],"exampleFix":"// before\nPUT .../variables/count   body: 42\n// after\nPUT .../variables/count   body: {\"name\":\"count\",\"value\":42,\"type\":\"integer\"}","handlingStrategy":"validation","validationCode":"let parsed; try { parsed = JSON.parse(body); } catch (e) { throw new Error('Body must be valid JSON RestVariable object'); }\nif (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) throw new Error('Body must be a RestVariable JSON object');","typeGuard":"function isRestVariable(b) { return b != null && typeof b === 'object' && !Array.isArray(b) && typeof b.name === 'string'; }","tryCatchPattern":"try { await api.put(url, body, { headers: {'Content-Type':'application/json'} }); }\ncatch (e) { if (/converting request body/i.test(e.message)) logAndInspectCause(e); else throw e; }","preventionTips":["Send JSON objects, never bare scalars","Set Content-Type: application/json","Validate body against the RestVariable schema before sending"],"tags":["rest","json","deserialization"],"backgroundTag":"json-unmarshal-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"}