flowable/flowable-engine · error · FlowableIllegalArgumentException

Converter can only convert integers

Error message

Converter can only convert integers

What it means

IntegerRestVariableConverter.getVariableValue narrows an engine variable value to an int via Number.intValue(). A non-null value that is not a Number cannot be converted and triggers this FlowableIllegalArgumentException.

Source

Thrown at modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/IntegerRestVariableConverter.java:37

 * @author Frederik Heremans
 */
public class IntegerRestVariableConverter implements RestVariableConverter {

    @Override
    public String getRestTypeName() {
        return "integer";
    }

    @Override
    public Class<?> getVariableType() {
        return Integer.class;
    }

    @Override
    public Object getVariableValue(EngineRestVariable result) {
        if (result.getValue() != null) {
            if (!(result.getValue() instanceof Number)) {
                throw new FlowableIllegalArgumentException("Converter can only convert integers");
            }
            return ((Number) result.getValue()).intValue();
        }
        return null;
    }

    @Override
    public void convertVariableValue(Object variableValue, EngineRestVariable result) {
        if (variableValue != null) {
            if (!(variableValue instanceof Integer)) {
                throw new FlowableIllegalArgumentException("Converter can only convert integers");
            }
            result.setValue(variableValue);
        } else {
            result.setValue(null);
        }
    }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Request the variable with the REST type matching the stored value (e.g. 'string').
  2. Store the value as an Integer (or numeric type) via runtimeService.setVariable.
  3. Parse numeric strings to Integer before storing them in the engine.
  4. Check the converter registry for a wrongly mapped 'integer' type.

Example fix

// before
runtimeService.setVariable(executionId, "count", "42");
// after
runtimeService.setVariable(executionId, "count", 42);
Defensive patterns

Strategy: type-guard

Validate before calling

public static boolean isIntegerCompatible(Object v) { return v == null || v instanceof Number; }

Type guard

public static boolean isNumber(Object v) { return v instanceof Number; }

Try / catch

try {
    Object n = restClient.getVariable(id, "count");
} catch (FlowableIllegalArgumentException e) {
    if (e.getMessage().equals("Converter can only convert integers")) {
        // fix stored type or request with matching REST type
    } else { throw e; }
}

Prevention

When it happens

Trigger: Reading a REST variable typed as 'integer' when the stored engine value is a String, Boolean, Date, or other non-numeric object.

Common situations: Variable stored as string "42" but requested as integer type; form data persisted as strings; manual edits to variable tables; converter type-name misconfiguration.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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