{"record":{"id":"c43488d444d45a9c","repo":"flowable/flowable-engine","slug":"the-variable-does-not-have-a-binary-data-stream-c43488","errorCode":null,"errorMessage":"The variable does not have a binary data stream.","messagePattern":"The variable does not have a binary data stream\\.","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricProcessInstanceVariableDataResource.java","lineNumber":81,"sourceCode":"    public byte[] getVariableData(@ApiParam(name = \"processInstanceId\") @PathVariable(\"processInstanceId\") String processInstanceId, \n                    @ApiParam(name = \"variableName\") @PathVariable(\"variableName\") String variableName, HttpServletResponse response) {\n        try {\n            byte[] result = null;\n            RestVariable variable = getVariableFromRequest(true, processInstanceId, variableName);\n            if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {\n                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 exception getting variable data\", ioe);\n        }\n    }\n\n    public RestVariable getVariableFromRequest(boolean includeBinary, String processInstanceId, String variableName) {\n\n        HistoricProcessInstance processObject = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();\n\n        if (processObject == null) {\n            throw new FlowableObjectNotFoundException(\"Historic process instance '\" + processInstanceId + \"' could not be found.\", HistoricProcessInstanceEntity.class);\n        }\n        \n        if (restApiInterceptor != null) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricProcessInstanceVariableDataResource.java#L63-L99","documentation":"The variable data endpoint streams the variable's raw bytes, but only for byte-array/binary/serializable variables. When the fetched historic variable holds no binary payload (e.g. a plain string/number variable, or a serializable whose value is null), FlowableObjectNotFoundException \"The variable does not have a binary data stream.\" is thrown.","triggerScenarios":"GET /history/process-instances/{id}/variables/{name}/data on a variable whose type is not byte-array, binary, or serializable (or a serializable variable with null value).","commonSituations":"Iterating all variables and requesting /data for each without checking type; variables whose type changed between engine versions; requesting data endpoints for string variables stored by custom field UIs.","solutions":["Check the variable's type via the variable endpoint (GET .../variables/{name}) and only call /data for binary/serializable/byte-array types","Read non-binary values from the variable's value field instead of the data endpoint","Fix the variable's type at write time if it should have been a byte array"],"exampleFix":"// before\nGET /history/process-instances/pi-1/variables/approver/data      // string variable -> 404\n// after\nGET /history/process-instances/pi-1/variables/approver            // plain value\n// or, for binaries:\nGET /history/process-instances/pi-1/variables/attachmentBytes/data","handlingStrategy":"validation","validationCode":"const v = await get(`/history/process-instances/${pid}/variables/${name}`); if (!['binary','byteArray','serializable'].includes(v.type)) throw new Error('not a binary variable');","typeGuard":"const isBinaryType = (v) => ['binary','byteArray','serializable'].includes(v?.type);","tryCatchPattern":"catch (e) { if (e.response && e.response.status === 404 && /binary data stream/.test(e.response.data.message)) { /* fall back to plain value endpoint */ } throw e; }","preventionTips":["Check the variable type before calling the /data endpoint","Use the plain variable endpoint for scalar values","Ensure variables intended as files are stored with byte-array/binary type"],"tags":["rest-api","variables","binary-data","resource-not-found"],"backgroundTag":"resource-not-found","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"}