{"record":{"id":"4b9fd8b9f8b17aeb","repo":"flowable/flowable-engine","slug":"error-negate","errorCode":"error.negate","errorMessage":"error.negate","messagePattern":"error\\.negate","errorType":"exception","errorClass":"ELException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/misc/NumberOperations.java","lineNumber":178,"sourceCode":"\t\tif (value instanceof String) {\n\t\t\tif (isDotEe((String)value)) {\n\t\t\t\treturn Double.valueOf(-converter.convert(value, Double.class).doubleValue());\n\t\t\t}\n\t\t\treturn Long.valueOf(-converter.convert(value, Long.class).longValue());\n\t\t}\n\t\tif (value instanceof Long) {\n\t\t\treturn Long.valueOf(-((Long)value).longValue());\n\t\t}\n\t\tif (value instanceof Integer) {\n\t\t\treturn Integer.valueOf(-((Integer)value).intValue());\n\t\t}\n\t\tif (value instanceof Short) {\n\t\t\treturn Short.valueOf((short)-((Short)value).shortValue());\n\t\t}\n\t\tif (value instanceof Byte) {\n\t\t\treturn Byte.valueOf((byte)-((Byte)value).byteValue());\n\t\t}\n\t\tthrow new ELException(LocalMessages.get(\"error.negate\", value.getClass()));\n\t}\n}\n","sourceCodeStart":160,"sourceCodeEnd":181,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/misc/NumberOperations.java#L160-L181","documentation":"NumberOperations.neg applies unary minus to an EL operand. After attempting coercion to known numeric types (Long, Double, ... Short, Byte), if the value's type is not supported it throws an ELException with 'error.negate' naming the value's class.","triggerScenarios":"Evaluating a unary minus expression like -x where x is neither a number nor coercible to one (e.g. a String that is not numeric, a boolean, or a POJO).","commonSituations":"Negating a non-numeric bean property in an expression; property type changed from a number to String/Boolean; passing BigDecimal-like custom types not handled by the converter.","solutions":["Ensure the negated operand is a numeric type (Integer, Long, Double, Float, Short, Byte, BigInteger, BigDecimal).","Convert non-numeric values explicitly in the expression or in the bean (e.g. expose a numeric getter).","Register/extend a TypeConverter so the value can be coerced to a number before negation."],"exampleFix":"// before: #{-flag} where flag is Boolean\n// after: expose count and use #{-count} where count is int\n// or: #{0 - someNumber} on a numeric property","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Number)) {\n    throw new IllegalArgumentException(\"unary minus requires a numeric operand, got: \" + (value == null ? \"null\" : value.getClass().getName()));\n}","typeGuard":"boolean isNumericOperand(Object o) {\n    return o instanceof Number;\n}","tryCatchPattern":"try {\n    Object r = NumberOperations.neg(converter, value);\n} catch (ELException e) {\n    // operand not numeric; coerce to a number before negating\n}","preventionTips":["Only apply unary minus to numeric-typed properties.","Keep bean getters that participate in arithmetic returning numeric types.","Convert String/Boolean values to numbers explicitly before arithmetic in expressions."],"tags":["el","arithmetic","type-mismatch","unary-operator","flowable"],"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"}