flowable/flowable-engine · error · FlowableIllegalArgumentException
Converter can only convert longs
Error message
Converter can only convert longs
What it means
LongRestVariableConverter.getVariableValue converts a REST variable into a java.lang.Long and requires the REST value to be a Number. If the value is any other type it throws FlowableIllegalArgumentException, since only numeric JSON values can be narrowed via Number.longValue().
Solutions
- Send the value as an unquoted JSON number (e.g. 123, not "123").
- Parse numeric strings with Long.parseLong client-side before posting.
- Verify the REST variable type marker matches the payload (integer vs long vs string).
- Fix client serialization that quotes all values (e.g. Map<String, String> payloads).
Example fix
// before
{ "type": "long", "value": "123" }
// after
{ "type": "long", "value": 123 } Defensive patterns
Strategy: validation
Validate before calling
if (!(rawValue instanceof Number)) {
throw new IllegalArgumentException("long variable must be a JSON number, got: "
+ (rawValue == null ? "null" : rawValue.getClass().getSimpleName()));
} Type guard
static boolean isNumeric(Object v) {
return v instanceof Number;
} Try / catch
try {
Object value = converter.getVariableValue(restVar);
} catch (FlowableIllegalArgumentException e) {
log.error("long variable value is not numeric: {}", restVar.getValue(), e);
} Prevention
- Post IDs and counts as unquoted JSON numbers.
- Parse numeric strings with Long.parseLong on the client before sending.
- Use typed clients/DTOs with long fields so serialization preserves numeric JSON.
When it happens
Trigger: Sending a variable of REST type long whose value is a String (e.g. "123"), boolean, array, or object, so result.getValue() fails the Number instanceof check in getVariableValue.
Common situations: Clients posting numeric IDs as quoted strings; form/query inputs kept as text; JSON frameworks that deserialize numbers into Strings or BigDecimal wrappers unexpectedly (BigDecimal is fine, but String is not).
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 integers
- Converter can only convert…
- Converter can only convert localDate
- Converter can only convert localDateTime
- Converter can only convert shorts
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/75b45005f8480d86.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LongRestVariableConverter.java:37
* @author Frederik Heremans
*/
public class LongRestVariableConverter implements RestVariableConverter {
@Override
public String getRestTypeName() {
return "long";
}
@Override
public Class<?> getVariableType() {
return Long.class;
}
@Override
public Object getVariableValue(EngineRestVariable result) {
if (result.getValue() != null) {
if (!(result.getValue() instanceof Number)) {
throw new FlowableIllegalArgumentException("Converter can only convert longs");
}
return ((Number) result.getValue()).longValue();
}
return null;
}
@Override
public void convertVariableValue(Object variableValue, EngineRestVariable result) {
if (variableValue != null) {
if (!(variableValue instanceof Long)) {
throw new FlowableIllegalArgumentException("Converter can only convert integers");
}
result.setValue(variableValue);
} else {
result.setValue(null);
}
}
View on GitHub (pinned to d6d39ce1c6)