{"record":{"id":"2f50a8c644a045aa","repo":"flowable/flowable-engine","slug":"the-variable-does-not-have-a-binary-data-stream-2f50a8","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-rest/src/main/java/org/flowable/rest/service/api/runtime/task/TaskVariableDataResource.java","lineNumber":78,"sourceCode":"            HttpServletResponse response) {\n        try {\n            byte[] result = null;\n\n            RestVariable variable = getVariableFromRequest(taskId, variableName, scope, true);\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 error getting variable data\", ioe);\n        }\n    }\n}\n","sourceCodeStart":60,"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#L60-L88","documentation":"The Flowable REST task variable data endpoint throws FlowableObjectNotFoundException when asked to return a variable's binary content but the variable's value is not serializable binary data (e.g. it is a plain string, integer, or other non-streamable type). The endpoint serializes the value with ObjectOutputStream only when the variable value is serializable; otherwise it cannot produce a binary stream and raises this error. It is a 404-style 'not found / not applicable' signal, since Flowable passes null for the object class.","triggerScenarios":"GET /runtime/tasks/{taskId}/variables/{variableName}/data where variableName refers to a variable whose value is not a Serializable object (or null), e.g. a variable set as a String/Integer/Boolean via the variables REST API, while the caller expects binary (serialized-object) content.","commonSituations":"Client assumes every task variable has downloadable binary data; variables created as simple types (string, long, json) are fetched via the /data endpoint; mismatch between how the variable was created (simple JSON body) and how it is fetched (data endpoint); null-valued variables.","solutions":["Fetch the variable via GET /runtime/tasks/{taskId}/variables/{variableName} instead of the /data endpoint to get its JSON representation.","Check the variable's type in the variables response; only Serializable (byte-array/serializable) variables have binary data.","If you need binary content, create the variable as a Serializable or byte[] value (e.g. set \"type\":\"serializable\" or upload via multipart) before fetching /data.","Handle 404 on the client and fall back to the regular variable endpoint."],"exampleFix":"// before\ncurl http://host/flowable-rest/runtime/tasks/123/variables/orderDoc/data\n// variable is a String, so it 404s with this message\n\n// after\ncurl http://host/flowable-rest/runtime/tasks/123/variables/orderDoc\n// returns {\"name\":\"orderDoc\",\"type\":\"string\",\"value\":\"...\"}","handlingStrategy":"validation","validationCode":"const vars = await fetch(`/runtime/tasks/${taskId}/variables`).then(r => r.json());\nconst v = vars.find(x => x.name === variableName);\nif (!v) throw new Error('variable not found');\nif (v.type !== 'serializable' && v.type !== 'byte-array' && v.valueUrl == null) {\n  // fetch JSON representation instead of /data\n}","typeGuard":"function hasBinaryData(variable) {\n  return variable != null &&\n    (variable.type === 'serializable' || variable.type === 'byte-array') &&\n    variable.valueUrl != null;\n}","tryCatchPattern":"try {\n  return await fetch(`${base}/runtime/tasks/${taskId}/variables/${name}/data`);\n} catch (e) {\n  if (e.status === 404) return fetch(`${base}/runtime/tasks/${taskId}/variables/${name}`); // JSON fallback\n  throw e;\n}","preventionTips":["Check the variable's type field in the variables listing before calling the /data endpoint.","Use the /data endpoint only for byte-array/serializable variables.","Treat 404 on /data as a signal to fall back to the JSON variable endpoint."],"tags":["rest-api","flowable","resource-not-found","variables"],"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"}