{"record":{"id":"5938f8bf9c10e2c6","repo":"flowable/flowable-engine","slug":"unexpected-error-getting-variable-data-5938f8","errorCode":null,"errorMessage":"Unexpected error getting variable data","messagePattern":"Unexpected error getting variable data","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableDataResource.java","lineNumber":84,"sourceCode":"                result = (byte[]) variable.getValue();\n                response.setContentType(\"application/octet-stream\");\n\n            } else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {\n                ByteArrayOutputStream buffer = new ByteArrayOutputStream();\n                ObjectOutputStream outputStream = new ObjectOutputStream(buffer);\n                outputStream.writeObject(variable.getValue());\n                outputStream.close();\n                result = buffer.toByteArray();\n                response.setContentType(\"application/x-java-serialized-object\");\n\n            } else {\n                throw new FlowableObjectNotFoundException(\"The variable does not have a binary data stream.\", null);\n            }\n            return result;\n\n        } catch (IOException ioe) {\n            // Re-throw IOException\n            throw new FlowableException(\"Unexpected error getting variable data\", ioe);\n        }\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":88,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableDataResource.java#L66-L88","documentation":"This FlowableException wraps any IOException that occurs while the task variable data endpoint serializes the variable value into a byte array (ObjectOutputStream -> ByteArrayOutputStream). Serialization of the variable's value failed unexpectedly, so the REST layer aborts with a generic 500-style server error. Unlike the not-found case, this indicates the variable looked binary but the I/O/serialization step itself blew up.","triggerScenarios":"GET /runtime/tasks/{taskId}/variables/{variableName}/data where the variable value IS serializable but ObjectOutputStream.writeObject throws an IOException during serialization (e.g. the stored object's class is not on the REST app's classpath, or an underlying stream/byte-array failure occurs).","commonSituations":"Serializable variable whose class was deployed in a different app/module so deserialization/serialization of fields fails (ClassNotFoundException wrapped in IOException); corrupted stored variable values; app classpath changes after the variable was stored.","solutions":["Inspect the cause (FlowableException#getCause) to find the underlying IOException and fix it (usually a missing class on the REST app classpath).","Ensure the class of the serialized variable value is available to the flowable-rest application's classpath.","Re-create the variable value as byte[] or a simple serializable type instead of a custom class.","If the stored value is corrupt, delete and re-set the variable, then retry the request."],"exampleFix":"// before: variable stores an app-specific object not on REST classpath\nruntimeService.setVariable(taskId, \"doc\", new OrderDocument());\n\n// after: store plain serializable content\nruntimeService.setVariable(taskId, \"doc\", orderDocument.toByteArray());","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const resp = await fetch(`${base}/runtime/tasks/${taskId}/variables/${name}/data`);\n  if (!resp.ok) {\n    const body = await resp.text();\n    if (resp.status === 500) logServerErrorCause(body); // inspect cause IOException server-side\n    throw new Error(`variable data failed: ${resp.status} ${body}`);\n  }\n  return resp.arrayBuffer();\n} catch (e) {\n  console.error('variable data serialization failed; check server logs for cause class', e);\n  throw e;\n}","preventionTips":["Only store classes on variables that are on the REST application's classpath.","Prefer byte[] or java.io.Serializable simple values over custom domain classes in variables.","After classpath changes or upgrades, re-verify stored serializable variables can be read.","Log FlowableException cause chain server-side to pinpoint the missing class."],"tags":["rest-api","flowable","io","serialization"],"backgroundTag":"file-read-failed","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"}