{"record":{"id":"c80bd6d60e4a96a5","repo":"apache/druid","slug":"unknown-type-s","errorCode":null,"errorMessage":"Unknown type [%s]","messagePattern":"Unknown type \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/Numbers.java","lineNumber":49,"sourceCode":"   * Parse the given object as a {@code long}. The input object can be a {@link String} or one of the implementations of\n   * {@link Number}. You may want to use {@code GuavaUtils.tryParseLong()} instead if the input is a nullable string and\n   * you want to avoid any exceptions.\n   *\n   * @throws NumberFormatException if the input is an unparseable string.\n   * @throws NullPointerException if the input is null.\n   * @throws ISE if the input is not a string or a number.\n   */\n  public static long parseLong(Object val)\n  {\n    if (val instanceof String) {\n      return Long.parseLong((String) val);\n    } else if (val instanceof Number) {\n      return ((Number) val).longValue();\n    } else {\n      if (val == null) {\n        throw new NullPointerException(\"Input is null\");\n      } else {\n        throw new ISE(\"Unknown type [%s]\", val.getClass());\n      }\n    }\n  }\n\n  /**\n   * Parse the given object as a {@code int}. The input object can be a {@link String} or one of the implementations of\n   * {@link Number}.\n   *\n   * @throws NumberFormatException if the input is an unparseable string.\n   * @throws NullPointerException if the input is null.\n   * @throws ISE if the input is not a string or a number.\n   */\n  public static int parseInt(Object val)\n  {\n    if (val instanceof String) {\n      return Integer.parseInt((String) val);\n    } else if (val instanceof Number) {\n      return ((Number) val).intValue();","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/Numbers.java#L31-L67","documentation":"Numbers.parseLong only accepts String and Number inputs; any other non-null object type is unsupported and triggers ISE \"Unknown type [class ...]\". The exception reports the value's actual class so the caller can see which unexpected type arrived.","triggerScenarios":"Calling Numbers.parseLong with a non-null object that is neither String nor Number, e.g. a Boolean, Date, byte[], List, or a custom POJO obtained from a generic map.","commonSituations":"JSON booleans or arrays landing in a field expected to be numeric; timestamp values as Date objects from upstream deserialization; mixed-type columns in generic Map-based rows.","solutions":["Coerce the value to String or Number before calling (e.g. String.valueOf(val) or ((Date) val).getTime())","Fix the upstream producer so the field is emitted as a number or numeric string","Add a type check/dispatch before parsing for heterogeneous inputs","Use a richer conversion utility (e.g. Jackson ObjectMapper.convertValue) that handles more types"],"exampleFix":"// before\nlong n = Numbers.parseLong(row.get(\"flag\")); // row value is Boolean\n// after\nObject v = row.get(\"flag\");\nlong n = v instanceof Boolean ? ((Boolean) v ? 1L : 0L) : Numbers.parseLong(v);","handlingStrategy":"type-guard","validationCode":"if (val != null && !(val instanceof String) && !(val instanceof Number)) {\n  throw new IllegalArgumentException(\"Expected String or Number, got \" + val.getClass().getName());\n}","typeGuard":"static boolean isParseableAsLong(Object val) {\n  return val instanceof String || val instanceof Number;\n}","tryCatchPattern":"try {\n  return Numbers.parseLong(val);\n} catch (IllegalStateException e) {\n  log.warn(\"Unsupported type for parseLong: {}\", val == null ? null : val.getClass());\n  return fallbackConversion(val);\n}","preventionTips":["Assert field types at deserialization boundaries","Normalize heterogeneous map rows to String/Number before conversion","Never pass Date/Boolean/byte[] to numeric parsers; convert explicitly","Document accepted input types (String | Number) for downstream users"],"tags":["type-mismatch","type-conversion","unsupported-type"],"backgroundTag":"type-mismatch","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}