{"record":{"id":"6d9b4b560c7d4a71","repo":"apache/druid","slug":"unknown-tablestate-code","errorCode":null,"errorMessage":"Unknown TableState code: ","messagePattern":"Unknown TableState code: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/catalog/model/TableMetadata.java","lineNumber":83,"sourceCode":"\n    TableState(String code)\n    {\n      this.code = code;\n    }\n\n    public String code()\n    {\n      return code;\n    }\n\n    public static TableState fromCode(String code)\n    {\n      for (TableState state : values()) {\n        if (state.code.equals(code)) {\n          return state;\n        }\n      }\n      throw new ISE(\"Unknown TableState code: \" + code);\n    }\n  }\n\n  private final TableId id;\n  private final long creationTime;\n  private final long updateTime;\n  private final TableState state;\n  private final TableSpec spec;\n\n  public TableMetadata(\n      @JsonProperty(\"id\") TableId tableId,\n      @JsonProperty(\"creationTime\") long creationTime,\n      @JsonProperty(\"updateTime\") long updateTime,\n      @JsonProperty(\"state\") TableState state,\n      @JsonProperty(\"spec\") TableSpec spec)\n  {\n    this.id = tableId;\n    this.creationTime = creationTime;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/catalog/model/TableMetadata.java#L65-L101","documentation":"TableState codes round-trip state through storage as short string codes. fromCode() throws ISE when given a code that matches no TableState enum value — this indicates corrupt or unrecognized persisted state data, since the enum cannot represent it.","triggerScenarios":"Calling TableState.fromCode(code) with a code string that is not one of the enum's defined codes, typically after deserializing TableMetadata from the metadata store.","commonSituations":"Manually editing metadata-store rows and writing an invalid state code; metadata written by a newer Druid version with a state code this version's enum lacks (downgrade); data corruption.","solutions":["Fix the stored state code in the metadata store to a valid TableState code","Check for version skew: if the metadata was written by a newer Druid, upgrade or revert the row","Inspect the code value being passed — it may be null/garbage from a failed deserialization"],"exampleFix":"// before\nTableState state = TableState.fromCode(\"ACTIVE\"); // not a defined code\n// after\nTableState state = TableState.fromCode(\"A\"); // use the enum's declared code","handlingStrategy":"try-catch","validationCode":"boolean knownCode = Arrays.stream(TableState.values()).anyMatch(s -> s.code.equals(code));\nif (!knownCode) { /* repair or reject the metadata row */ }","typeGuard":"TableState fromCodeOrNull(String code) {\n  return Arrays.stream(TableState.values()).filter(s -> s.code.equals(code)).findFirst().orElse(null);\n}","tryCatchPattern":"try { state = TableState.fromCode(code); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Unknown TableState code\")) { state = TableState.defaultState(); /* or quarantine the row */ } else { throw e; } }","preventionTips":["Never hand-edit metadata-store state codes","Use the enum constant (state.code()) when writing rows","Check version compatibility before downgrading Druid with existing metadata"],"tags":["enum","metadata-store","deserialization"],"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-14T05:17:10.506Z"}