{"record":{"id":"4201a75e28cdccd6","repo":"xai-org/x-algorithm","slug":"invalid-numeric-type-s","errorCode":null,"errorMessage":"Invalid numeric type (%s)","messagePattern":"Invalid numeric type \\((.+?)\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/function/math/Abs.java","lineNumber":53,"sourceCode":"  public Signature getSignature() {\n    return SIGNATURE;\n  }\n\n  @Override\n  protected CacheLevel getCacheLevel() {\n    return CacheLevel.Global;\n  }\n\n  @Override\n  public Object apply(Context<Runtime> context, Number num) {\n\n    if (Type.doubleLike(num)) {\n      return Math.abs(num.doubleValue());\n    } else if (Type.longLike(num)) {\n      return Math.abs(num.longValue());\n    }\n\n    throw new IllegalArgumentException(String.format(\"Invalid numeric type (%s)\", num));\n  }\n}\n","sourceCodeStart":35,"sourceCodeEnd":56,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/function/math/Abs.java#L35-L56","documentation":"Abs.apply throws IllegalArgumentException when the argument is a Number that is neither doubleLike nor longLike per the Type classifier. The Abs function only accepts numeric types it recognizes (double/float-like or long/int-like); anything else (e.g. BigDecimal, exotic Number subclasses) is rejected.","triggerScenarios":"Calling Abs() on a value whose runtime Number implementation is not classified as doubleLike or longLike by com.twitter.botmaker Type helpers, e.g. passing a BigDecimal or a custom Number subclass through the expression engine.","commonSituations":"Expressions built over data sources that produce BigDecimal/BigInteger (e.g. decimal columns from a database or JSON parser), or custom Number subclasses registered as botmaker return types.","solutions":["Convert the value to a Double or Long before passing it to Abs() (e.g. wrap with a ToDouble/ToLong conversion function in the expression)","Ensure the upstream function's declared return Type is a recognized numeric type (DoubleType/LongType etc.)","As a library maintainer, add BigDecimal handling or a clear numeric-type whitelist"],"exampleFix":"// before\nAbs().apply(ctx, new BigDecimal(\"-5\")) // -> IllegalArgumentException\n// after\nAbs().apply(ctx, -5.0) // Double is doubleLike\n","handlingStrategy":"validation","validationCode":"boolean isSupportedNumber(Number n) {\n  return Type.doubleLike(n) || Type.longLike(n);\n}\n// call before Abs().apply(ctx, num)","typeGuard":"public static boolean absApplicable(Object v) {\n  return v instanceof Number && (Type.doubleLike((Number) v) || Type.longLike((Number) v));\n}","tryCatchPattern":null,"preventionTips":["Standardize numeric values to Double/Long at data-ingestion boundaries","Avoid BigDecimal/custom Number subclasses in botmaker expressions","Add unit tests covering numeric type variants for math functions"],"tags":["math","type-mismatch","abs","numeric"],"backgroundTag":"invalid-numeric-type","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}