{"record":{"id":"478d7d217e7f4106","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-integers","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/IntegerRestVariableConverter.java","lineNumber":37,"sourceCode":" * @author Frederik Heremans\n */\npublic class IntegerRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"integer\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return Integer.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 integers\");\n            }\n            return ((Number) result.getValue()).intValue();\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof Integer)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert integers\");\n            }\n            result.setValue(variableValue);\n        } else {\n            result.setValue(null);\n        }\n    }\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/IntegerRestVariableConverter.java#L19-L55","documentation":"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.","triggerScenarios":"Reading a REST variable typed as 'integer' when the stored engine value is a String, Boolean, Date, or other non-numeric object.","commonSituations":"Variable stored as string \"42\" but requested as integer type; form data persisted as strings; manual edits to variable tables; converter type-name misconfiguration.","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."],"exampleFix":"// before\nruntimeService.setVariable(executionId, \"count\", \"42\");\n// after\nruntimeService.setVariable(executionId, \"count\", 42);","handlingStrategy":"type-guard","validationCode":"public static boolean isIntegerCompatible(Object v) { return v == null || v instanceof Number; }","typeGuard":"public static boolean isNumber(Object v) { return v instanceof Number; }","tryCatchPattern":"try {\n    Object n = restClient.getVariable(id, \"count\");\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().equals(\"Converter can only convert integers\")) {\n        // fix stored type or request with matching REST type\n    } else { throw e; }\n}","preventionTips":["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."],"tags":["rest","integer","type-mismatch","variable-converter"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}