{"record":{"id":"583ffc3f856936cf","repo":"flowable/flowable-engine","slug":"the-variable-does-not-have-a-binary-data-stream-583ffc","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":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java","lineNumber":160,"sourceCode":"    }\n\n    protected byte[] restVariableDataToRestResponse(RestVariable variable, HttpServletResponse response) {\n        byte[] result = null;\n        try {\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        } catch (IOException ioe) {\n            throw new FlowableException(\"Error getting variable \" + variable.getName(), ioe);\n        }\n        return result;\n    }\n\n    protected RestVariable constructRestVariable(String variableName, Object value, String caseInstanceId, int variableType, boolean includeBinary,\n            RestVariableScope scope) {\n        return restResponseFactory.createRestVariable(variableName, value, scope, caseInstanceId, variableType, includeBinary);\n    }\n\n    protected List<RestVariable> processCaseVariables(CaseInstance caseInstance) {\n\n        // Check if it's a valid execution to get the variables for\n        List<RestVariable> variables = addVariables(caseInstance);\n\n        // Get unique variables from map","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java#L142-L178","documentation":"Thrown by restVariableDataToRestResponse in BaseVariableResource when asked to return a variable's raw data (binary/serializable) but the variable's value is not a byte[] or Serializable object, so there is no binary stream to write. It is a FlowableObjectNotFoundException with a null id, indicating the requested resource representation does not exist for this variable.","triggerScenarios":"GET a case-instance variable with includeBinary/responsive data endpoint while the variable's value is a primitive/String/Date (e.g. GET /cmmn-runtime/case-instances/{id}/variables/{name}/data) — the value cannot be streamed as bytes.","commonSituations":"Clients assume every variable has downloadable binary content; variables set as JSON strings or numbers via the REST API are requested as /data endpoints; serializable variable support disabled so objects got deserialized into Strings.","solutions":["Request the variable via the variables endpoint (without /data) to get its typed JSON representation instead of the binary stream.","Check the variable's type first (GET .../variables/{name}) and only call /data for 'binary' or 'serializable' variables.","If the value should be binary, set it with the binary upload endpoint (multipart POST) so it is stored as a byte array."],"exampleFix":"// before\ncurl http://host/flowable-rest/cmmn-runtime/case-instances/{id}/variables/orderPdf/data\n// after\ncurl http://host/flowable-rest/cmmn-runtime/case-instances/{id}/variables/orderPdf   # check type first\n# only call /data when type is binary/serializable","handlingStrategy":"validation","validationCode":"const meta = await getVariable(caseInstanceId, name);\nif (!['binary', 'serializable'].includes(meta.type)) {\n  throw new Error(`Variable '${name}' has no binary data; type is ${meta.type}`);\n}\nconst data = await getVariableData(caseInstanceId, name);","typeGuard":"function hasBinaryStream(v) { return v && (v.type === 'binary' || v.type === 'serializable'); }","tryCatchPattern":"try {\n  return await getVariableData(id, name);\n} catch (e) {\n  if (isFlowableObjectNotFound(e)) return await getVariable(id, name); // typed JSON fallback\n  throw e;\n}","preventionTips":["Check the variable's type via the variables endpoint before requesting /data.","Only upload truly binary content through the multipart endpoint.","Handle FlowableObjectNotFoundException distinctly from generic errors."],"tags":["rest","variables","resource-not-found","cmmn"],"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-14T05:17:10.506Z"}