{"record":{"id":"3f8e861eb5a17d56","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-integers-3f8e86","errorCode":null,"errorMessage":"Converter can only convert integers","messagePattern":"Converter can only convert integers","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LongRestVariableConverter.java","lineNumber":48,"sourceCode":"        return Long.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        if (result.getValue() != null) {\n            if (!(result.getValue() instanceof Number)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert longs\");\n            }\n            return ((Number) result.getValue()).longValue();\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof Long)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert integers\");\n            }\n            result.setValue(variableValue);\n        } else {\n            result.setValue(null);\n        }\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LongRestVariableConverter.java#L30-L57","documentation":"LongRestVariableConverter.convertVariableValue serializes an engine variable to a REST variable and requires the value to be exactly java.lang.Long. Note the message says \"integers\" but the guard is instanceof Long: Integer, int, BigInteger, or other numeric types fail and throw FlowableIllegalArgumentException.","triggerScenarios":"Calling convertVariableValue with a non-null value that is not a Long — commonly an Integer, int (autoboxed), or BigInteger — when the variable is declared as a long REST type.","commonSituations":"Passing int/Integer literals into variable maps typed as long; ORM or JSON layers producing Integer/BigInteger; copy-paste from integer converters despite the misleading message text.","solutions":["Convert the value to Long first: Long.valueOf(((Number) v).longValue()).","Declare process variables as long/Long end-to-end so the engine stores java.lang.Long.","If you genuinely need Integer variables, use the IntegerRestVariableConverter instead.","Update the misleading message text in a patch if you maintain a fork, to say \"Converter can only convert Long\"."],"exampleFix":"// before\nint count = 42;\nconverter.convertVariableValue(count, restVar); // throws (autoboxed to Integer)\n\n// after\nconverter.convertVariableValue(Long.valueOf(count), restVar);","handlingStrategy":"type-guard","validationCode":"if (value instanceof Long) {\n    converter.convertVariableValue(value, restVar);\n} else if (value instanceof Number n) {\n    converter.convertVariableValue(n.longValue(), restVar);\n} else {\n    throw new IllegalArgumentException(\"Cannot serialize as long: \" + value.getClass());\n}","typeGuard":"static boolean isJavaLangLong(Object v) {\n    return v instanceof Long;\n}","tryCatchPattern":"try {\n    converter.convertVariableValue(value, restVar);\n} catch (FlowableIllegalArgumentException e) {\n    throw new IllegalStateException(\"long REST variable requires java.lang.Long, got: \"\n        + value.getClass().getName(), e);\n}","preventionTips":["Declare variables as long/Long end-to-end; avoid int/Integer for long-typed variables.","Wrap numeric literals explicitly with Long.valueOf before adding to variable maps.","Note the converter's message says 'integers' but the required type is Long — trust the instanceof, not the text."],"tags":["long","rest-variable","type-mismatch","number"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}