{"record":{"id":"c593f99dc465ce4d","repo":"flowable/flowable-engine","slug":"unexpected-exception-getting-variable-data-c593f9","errorCode":null,"errorMessage":"Unexpected exception getting variable data","messagePattern":"Unexpected exception getting variable data","errorType":"http","errorClass":"FlowableException","httpStatus":500,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/VariableInstanceDataResource.java","lineNumber":89,"sourceCode":"                result = (byte[]) variable.getValue();\n                response.setContentType(\"application/octet-stream\");\n\n            } else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {\n                try (ByteArrayOutputStream buffer = new ByteArrayOutputStream();\n                     ObjectOutputStream outputStream = new ObjectOutputStream(buffer)) {\n                    outputStream.writeObject(variable.getValue());\n                    result = buffer.toByteArray();\n                    response.setContentType(\"application/x-java-serialized-object\");\n                }\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 exception getting variable data\", ioe);\n        }\n    }\n\n    public RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId) {\n        VariableInstance varObject = runtimeService.createVariableInstanceQuery().id(varInstanceId).singleResult();\n\n        if (varObject == null) {\n            throw new FlowableObjectNotFoundException(\"Historic variable instance '\" + varInstanceId + \"' could not be found.\", VariableInstanceEntity.class);\n        } else {\n            \n            if (restApiInterceptor != null) {\n                restApiInterceptor.accessVariableInfoById(varObject);\n            }\n            \n            return restResponseFactory.createRestVariable(varObject.getName(), varObject.getValue(), null, varInstanceId, RestResponseFactory.VARIABLE_VARINSTANCE, includeBinary);\n        }\n    }\n}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/runtime/VariableInstanceDataResource.java#L71-L107","documentation":"This FlowableException wraps an IOException thrown while reading the binary/stream content of a runtime variable in the REST API. It indicates the server failed at the I/O level when serializing or deserializing the variable's data (e.g. reading a byte array or serializable object), not that the variable is missing. The original IOException is attached as the cause.","triggerScenarios":"Calling GET on a variable instance data endpoint (VariableInstanceDataResource.getVariableData) where the variable holds binary or serializable data and the underlying stream read/write throws IOException, e.g. corrupted or unavailable variable byte content during toByteArray/writeObject.","commonSituations":"Large serialized variables whose stream fails mid-read; database storing truncated byte arrays; serialization incompatibility when the stored object graph cannot be written; environment/classloader issues during object serialization.","solutions":["Inspect the wrapped IOException cause in logs to find the real I/O failure","Re-set the variable with fresh binary/serializable content via the REST API to replace corrupted data","Verify the flowable variable storage (DB blob columns) is intact and not truncated","Upgrade/align Flowable version to get fixes for variable stream handling"],"exampleFix":"// before\nRestVariable result = getVariableData(...); // throws opaque FlowableException\n// after\ntry {\n    RestVariable result = getVariableData(...);\n} catch (FlowableException e) {\n    logger.error(\"variable data I/O failed\", e.getCause());\n    // re-set the variable or return 500 with cause detail\n}","handlingStrategy":"try-catch","validationCode":"VariableInstance v = runtimeService.createVariableInstanceQuery().id(id).singleResult();\nboolean safe = v != null && (v.getValue() instanceof byte[] || \"serializable\".equals(v.getType()));","typeGuard":"boolean hasBinaryStream(VariableInstance v) {\n    return v != null && v.getValue() instanceof byte[];\n}","tryCatchPattern":"try {\n    RestVariable data = resource.getVariableData(...);\n} catch (FlowableException e) {\n    log.error(\"variable data I/O failure\", e.getCause());\n    throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, \"variable data unavailable\");\n}","preventionTips":["Confirm the variable type before requesting binary data","Monitor variable blob integrity in the database","Keep Flowable engine and classpaths consistent for serializable variables","Always log the exception cause, not just the message"],"tags":["io","rest-api","variables","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-14T05:17:10.506Z"}