{"record":{"id":"d1e756a9b7e57d8f","repo":"flowable/flowable-engine","slug":"the-variable-does-not-have-a-binary-data-stream-d1e756","errorCode":null,"errorMessage":"The variable does not have a binary data stream.","messagePattern":"The variable does not have a binary data stream\\.","errorType":"http","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"warning","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/task/HistoricTaskInstanceVariableDataResource.java","lineNumber":85,"sourceCode":"            HttpServletResponse response) {\n\n        try {\n            byte[] result = null;\n            RestVariable variable = getVariableFromRequest(true, taskId, variableName, scope);\n            if (CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {\n                result = (byte[]) variable.getValue();\n                response.setContentType(\"application/octet-stream\");\n\n            } else if (CmmnRestResponseFactory.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 taskId, String variableName, String scope) {\n        RestVariableScope variableScope = RestVariable.getScopeFromString(scope);\n        HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskId(taskId);\n\n        if (variableScope != null) {\n            if (variableScope == RestVariableScope.GLOBAL) {\n                taskQuery.includeProcessVariables();\n            } else {\n                taskQuery.includeTaskLocalVariables();","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/history/task/HistoricTaskInstanceVariableDataResource.java#L67-L103","documentation":"FlowableObjectNotFoundException thrown when fetching raw variable data for a historic task whose variable is neither a byte-array (binary) nor a serializable value — i.e. it has no binary stream to return. The endpoint /cmmn-history/historic-task-instances/{taskId}/variables/{variableName}/data only serves byte[] and Serializable variables; plain string/number/boolean variables hit this error.","triggerScenarios":"GET /cmmn-history/historic-task-instances/{taskId}/variables/{variableName}/data where the variable is a primitive type (String, Integer, Boolean, Date, etc.) with no byte-array or serializable payload.","commonSituations":"Trying to download a variable that is a JSON string or number as if it were a file upload; scripts that download all variables via the /data endpoint assuming all are binary; confusion between the plain variable endpoint and the raw-data endpoint.","solutions":["Use the plain variable endpoint GET .../variables/{variableName} instead of .../variables/{variableName}/data for non-binary variables","Check the variable's type in the variable list response; only byte-array/serializable/binary types have raw data","If you need the value of a string/number variable, read it from the normal REST variable representation (JSON)","If the variable was expected to be binary, verify the process/case actually stored it as byte[] or Serializable"],"exampleFix":"// before\nbyte[] data = get(\"/cmmn-history/historic-task-instances/\" + taskId + \"/variables/\" + name + \"/data\");\n// after\nRestVariable v = getVariable(taskId, name);\nbyte[] data = v.getType().isBinary() ? getRawData(taskId, name) : String.valueOf(v.getValue()).getBytes();","handlingStrategy":"validation","validationCode":"const vars = await fetch(`/cmmn-history/historic-task-instances/${taskId}/variables`).then(r => r.json());\nconst v = vars.find(v => v.name === variableName);\nif (!['byteArray','binary','serializable'].includes(v.type)) return v.value; // read via plain endpoint","typeGuard":"function hasBinaryStream(variable) {\n  return variable != null && ['byteArray','binary','serializable'].includes(variable.type);\n}","tryCatchPattern":"try {\n  return await fetchVariableData(taskId, name);\n} catch (e) {\n  if (String(e.message).includes('binary data stream')) return fetchPlainVariable(taskId, name);\n  throw e;\n}","preventionTips":["List variables first and inspect the type field before calling the /data endpoint","Only use /data for byte-array and serializable variables; use the plain variable endpoint otherwise","Don't assume all task variables are file uploads","Document in your client which variable types support raw data download"],"tags":["rest","variables","binary-data","historical-data"],"backgroundTag":"incompatible-source-type","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"}