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
- Request the variable with the REST type matching the stored value (e.g. 'string').
- Store the value as an Integer (or numeric type) via runtimeService.setVariable.
- Parse numeric strings to Integer before storing them in the engine.
- 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
- Store counters/counts as Integer via engine APIs, not strings.
- Keep REST type declarations and stored Java types in sync.
- Validate form input as numeric before persisting.
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
- Converter can only convert booleans
- Converter can only convert doubles
- Converter can only convert string to instant
- Converter can only convert instant
- Variable '${restVariable.getName()}' has unsupported type: '
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/478d7d217e7f4106.
Report an issue: GitHub.