flowable/flowable-engine · error · FlowableObjectNotFoundException

The variable does not have a binary data stream.

Error message

The variable does not have a binary data stream.

What it means

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.

Source

Thrown at modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/runtime/caze/BaseVariableResource.java:160

    }

    protected byte[] restVariableDataToRestResponse(RestVariable variable, HttpServletResponse response) {
        byte[] result = null;
        try {
            if (CmmnRestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
                result = (byte[]) variable.getValue();
                response.setContentType("application/octet-stream");

            } else if (CmmnRestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
                outputStream.writeObject(variable.getValue());
                outputStream.close();
                result = buffer.toByteArray();
                response.setContentType("application/x-java-serialized-object");

            } else {
                throw new FlowableObjectNotFoundException("The variable does not have a binary data stream.", null);
            }
        } catch (IOException ioe) {
            throw new FlowableException("Error getting variable " + variable.getName(), ioe);
        }
        return result;
    }

    protected RestVariable constructRestVariable(String variableName, Object value, String caseInstanceId, int variableType, boolean includeBinary,
            RestVariableScope scope) {
        return restResponseFactory.createRestVariable(variableName, value, scope, caseInstanceId, variableType, includeBinary);
    }

    protected List<RestVariable> processCaseVariables(CaseInstance caseInstance) {

        // Check if it's a valid execution to get the variables for
        List<RestVariable> variables = addVariables(caseInstance);

        // Get unique variables from map

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Request the variable via the variables endpoint (without /data) to get its typed JSON representation instead of the binary stream.
  2. Check the variable's type first (GET .../variables/{name}) and only call /data for 'binary' or 'serializable' variables.
  3. If the value should be binary, set it with the binary upload endpoint (multipart POST) so it is stored as a byte array.

Example fix

// before
curl http://host/flowable-rest/cmmn-runtime/case-instances/{id}/variables/orderPdf/data
// after
curl http://host/flowable-rest/cmmn-runtime/case-instances/{id}/variables/orderPdf   # check type first
# only call /data when type is binary/serializable
Defensive patterns

Strategy: validation

Validate before calling

const meta = await getVariable(caseInstanceId, name);
if (!['binary', 'serializable'].includes(meta.type)) {
  throw new Error(`Variable '${name}' has no binary data; type is ${meta.type}`);
}
const data = await getVariableData(caseInstanceId, name);

Type guard

function hasBinaryStream(v) { return v && (v.type === 'binary' || v.type === 'serializable'); }

Try / catch

try {
  return await getVariableData(id, name);
} catch (e) {
  if (isFlowableObjectNotFound(e)) return await getVariable(id, name); // typed JSON fallback
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/583ffc3f856936cf. Report an issue: GitHub.