{"record":{"id":"b81cd29e76d87736","repo":"apache/druid","slug":"there-is-no-format-for-type-s","errorCode":null,"errorMessage":"There is no format for type %s","messagePattern":"There is no format for type (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/granularity/PeriodGranularity.java","lineNumber":118,"sourceCode":"  public DateTime getOrigin()\n  {\n    return hasOrigin ? DateTimes.utc(origin) : null;\n  }\n\n  // Used only for Segments. Not for Queries\n  @Override\n  public DateTimeFormatter getFormatter(Formatter type)\n  {\n    GranularityType granularityType = GranularityType.fromPeriod(period);\n    switch (type) {\n      case DEFAULT:\n        return DateTimeFormat.forPattern(granularityType.getDefaultFormat());\n      case HIVE:\n        return DateTimeFormat.forPattern(granularityType.getHiveFormat());\n      case LOWER_DEFAULT:\n        return DateTimeFormat.forPattern(granularityType.getLowerDefaultFormat());\n      default:\n        throw new IAE(\"There is no format for type %s\", type);\n    }\n  }\n\n  @Override\n  public long bucketStart(long time)\n  {\n    return truncate(time);\n  }\n\n  @Override\n  public long increment(long t)\n  {\n    return chronology.add(period, t, 1);\n  }\n\n  @Override\n  public DateTime increment(DateTime time)\n  {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/granularity/PeriodGranularity.java#L100-L136","documentation":"PeriodGranularity.getFormatter(Formatter) selects a DateTimeFormatter pattern based on the Formatter enum (DEFAULT, HIVE, LOWER_DEFAULT). The default branch throws IAE when a Formatter value has no corresponding case — an unhandled formatter type in this switch.","triggerScenarios":"Calling PeriodGranularity.getFormatter with a Formatter constant not covered by the switch (added enum variant or a caller passing a custom/new Formatter type).","commonSituations":"Code written against a newer Formatter enum than this Druid version supports; generic formatting utilities that pass through all enum values.","solutions":["Pass one of the supported Formatter values: DEFAULT, HIVE, or LOWER_DEFAULT","Upgrade Druid if you rely on a newer Formatter variant added in a later version","Handle the new enum value explicitly in caller code before invoking getFormatter"],"exampleFix":"// before\nDateTimeFormatter fmt = granularity.getFormatter(myCustomFormatter);\n// after\nDateTimeFormatter fmt = granularity.getFormatter(Formatter.Type.DEFAULT); // supported value","handlingStrategy":"validation","validationCode":"if (type != Formatter.Type.DEFAULT && type != Formatter.Type.HIVE && type != Formatter.Type.LOWER_DEFAULT) {\n  type = Formatter.Type.DEFAULT;\n}","typeGuard":"boolean isSupportedFormatter = type == Formatter.Type.DEFAULT || type == Formatter.Type.HIVE || type == Formatter.Type.LOWER_DEFAULT;","tryCatchPattern":"try { fmt = granularity.getFormatter(type); } catch (IllegalArgumentException e) { fmt = granularity.getFormatter(Formatter.Type.DEFAULT); }","preventionTips":["Pass only the enum values handled by getFormatter","Pin Druid version if you rely on a specific Formatter enum surface","Switch on Formatter in caller code rather than passing opaque values"],"tags":["granularity","formatter","invalid-enum-value","druid"],"backgroundTag":"invalid-enum-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}