{"record":{"id":"38dcd3248d4e2a2f","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-shorts","errorCode":null,"errorMessage":"Converter can only convert shorts","messagePattern":"Converter can only convert shorts","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/ShortRestVariableConverter.java","lineNumber":37,"sourceCode":" * @author Frederik Heremans\n */\npublic class ShortRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"short\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return Short.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 shorts\");\n            }\n            return ((Number) result.getValue()).shortValue();\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof Short)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert shorts\");\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/ShortRestVariableConverter.java#L19-L55","documentation":"ShortRestVariableConverter.getVariableValue converts an engine REST variable value back into a Short. If the raw value stored in EngineRestVariable is not a java.lang.Number, the converter cannot narrow it to a short and throws FlowableIllegalArgumentException. This is an internal type-invariant check protecting the REST variable type system.","triggerScenarios":"Calling getVariableValue on an EngineRestVariable whose getValue() returns a non-Number object (e.g. a String or custom object) while this converter is registered as the handler for the 'short' REST variable type.","commonSituations":"A variable stored/passed with a mismatched type (string '5' instead of numeric 5), a custom converter chain or deserializer producing the wrong Java type, or someone registering ShortRestVariableConverter for the wrong variable type name.","solutions":["Ensure the variable value is stored as a numeric type (Integer/Long/Short/BigDecimal) before REST conversion.","Fix the client/serializer that is sending a non-numeric value for a short-typed variable.","Verify the converter's getTypeName()/getVariableType mapping matches the actual variable type being converted."],"exampleFix":"// before\nresult.setValue(\"42\"); // string set for short variable\n// after\nresult.setValue(42); // numeric value the short converter can handle","handlingStrategy":"type-guard","validationCode":"if (result.getValue() != null && !(result.getValue() instanceof Number)) {\n    throw new IllegalArgumentException(\"Expected numeric value for short variable, got: \" + result.getValue().getClass());\n}","typeGuard":"static boolean isNumeric(Object v) { return v instanceof Number; }","tryCatchPattern":"try {\n    Object v = converter.getVariableValue(result);\n} catch (FlowableIllegalArgumentException e) {\n    // inspect result.getValue() type, log and fall back to default short\n}","preventionTips":["Always store short variables as numeric types, never strings.","Unit-test converter registration mappings against variable types.","Validate payloads deserialized from JSON before assigning to EngineRestVariable."],"tags":["type-mismatch","rest-variable","conversion"],"backgroundTag":"incompatible-source-type","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"}