{"record":{"id":"74c88fe67424d9b2","repo":"apache/druid","slug":"value-s-is-not-valid-for-property-s-expecte","errorCode":null,"errorMessage":"Value [%s] is not valid for property [%s], expected type [%s]","messagePattern":"Value \\[(.+?)\\] is not valid for property \\[(.+?)\\], expected type \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/CatalogUtils.java","lineNumber":110,"sourceCode":"   */\n  public static List<String> stringToList(String value)\n  {\n    if (value == null) {\n      return null;\n    }\n    return Arrays.asList(value.split(\",\\\\s*\"));\n  }\n\n  public static <T> T safeCast(Object value, Class<T> type, String key)\n  {\n    if (value == null) {\n      return null;\n    }\n    try {\n      return type.cast(value);\n    }\n    catch (ClassCastException e) {\n      throw new IAE(\"Value [%s] is not valid for property [%s], expected type [%s]\",\n          value,\n          key,\n          type.getSimpleName()\n      );\n    }\n  }\n\n  public static <T> T safeGet(Map<String, Object> map, String key, Class<T> type)\n  {\n    return safeCast(map.get(key), type, key);\n  }\n\n  public static long getLong(Map<String, Object> map, String key)\n  {\n    Object value = map.get(key);\n    if (value == null) {\n      return 0;\n    }","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/CatalogUtils.java#L92-L128","documentation":"Thrown by CatalogUtils.safeCast when a catalog table property value exists but cannot be cast to the expected type via type.cast(value), i.e. ClassCastException. It reports the offending value, property key, and expected type name so the misconfigured table definition can be corrected.","triggerScenarios":"Calling safeGet/getLong/getStringArray (or safeCast directly) on a table property whose stored value type differs from the expected one - e.g. a string '123' where a Long is expected, a scalar where List<String> is expected, or JSON deserialization yielding a different concrete type.","commonSituations":"Hand-edited catalog JSON where numbers are quoted as strings, schema changes between Druid versions altering a property's type, programmatic updates writing Integer where Long is required (Integer cannot be cast to Long).","solutions":["Correct the table property value to the expected type (e.g. unquoted number for Long, JSON array of strings for string arrays)","Inspect the persisted table definition and compare each property against the TableDefn schema","If updating programmatically, wrap numbers in the exact expected boxed type (Long, not Integer)"],"exampleFix":"// before\n{\"targetLoadOnly\": \"true\"}\n// after\n{\"targetLoadOnly\": true}","handlingStrategy":"type-guard","validationCode":"if (value instanceof String && expected == Long.class) {\n  // pre-coerce or reject: \"123\" will fail cast\n}\nif (expected == List.class && !(value instanceof List)) {\n  throw new IllegalArgumentException(\"Property must be a JSON array\");\n}","typeGuard":"static <T> boolean isAssignable(Object value, Class<T> type) {\n  return type.isInstance(value);\n}\n// usage: if (!isAssignable(props.get(key), Long.class)) fix before safeGet;","tryCatchPattern":"try {\n  Long v = CatalogUtils.safeGet(props, \"someLong\", Long.class);\n} catch (IllegalArgumentException e) {\n  log.error(\"Bad property type: {}\", e.getMessage());\n}","preventionTips":["Store JSON-typed values (unquoted numbers, real arrays) in table properties","Round-trip definitions through the object mapper to normalize types","Watch for Integer vs Long when building properties programmatically"],"tags":["catalog","type-mismatch","validation"],"backgroundTag":"type-mismatch","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}