{"record":{"id":"426bb35adf39be76","repo":"apache/iceberg","slug":"unknown-delete-granularity","errorCode":null,"errorMessage":"Unknown delete granularity: ","messagePattern":"Unknown delete granularity: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/deletes/DeleteGranularity.java","lineNumber":57,"sourceCode":" * <p>Currently, this configuration is only applicable to position deletes.\n *\n * <p>Each granularity has its own benefits and drawbacks and should be picked based on a use case.\n * Regular delete compaction is still required regardless of which granularity is chosen. It is also\n * possible to use one granularity for ingestion and another one for table maintenance.\n */\npublic enum DeleteGranularity {\n  FILE,\n  PARTITION;\n\n  @Override\n  public String toString() {\n    switch (this) {\n      case FILE:\n        return \"file\";\n      case PARTITION:\n        return \"partition\";\n      default:\n        throw new IllegalArgumentException(\"Unknown delete granularity: \" + this);\n    }\n  }\n\n  public static DeleteGranularity fromString(String valueAsString) {\n    Preconditions.checkArgument(valueAsString != null, \"Value is null\");\n    if (FILE.toString().equalsIgnoreCase(valueAsString)) {\n      return FILE;\n    } else if (PARTITION.toString().equalsIgnoreCase(valueAsString)) {\n      return PARTITION;\n    } else {\n      throw new IllegalArgumentException(\"Unknown delete granularity: \" + valueAsString);\n    }\n  }\n}\n","sourceCodeStart":39,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/deletes/DeleteGranularity.java#L39-L72","documentation":"DeleteGranularity.toString() converts the enum constant to its lowercase string form (\"file\" or \"partition\") and throws IllegalArgumentException in the default branch. This can only fire if a new enum constant was added without updating toString, or the default case is reached in a switch over the enum.","triggerScenarios":"Internally: a DeleteGranularity enum constant lacking a case in the toString switch. Practically unreachable for users of the released enum with only FILE and PARTITION.","commonSituations":"Custom patched builds adding a new granularity without updating toString; internal invariant violation during configuration rendering or metadata serialization.","solutions":["Add a case for the missing enum constant in the toString switch.","Use only the released constants FILE and PARTITION.","Report an internal invariant violation upstream if encountered with an unmodified release."],"exampleFix":"// before\ncase PARTITION: return \"partition\";\ndefault: throw new IllegalArgumentException(...);\n// after\ncase PARTITION: return \"partition\";\ncase ROW: return \"row\"; // new constant handled\ndefault: throw new IllegalArgumentException(...);","handlingStrategy":"type-guard","validationCode":"null","typeGuard":"if (g == DeleteGranularity.FILE || g == DeleteGranularity.PARTITION) { /* safe to use g.toString() */ }","tryCatchPattern":"try { return granularity.toString(); } catch (IllegalArgumentException e) { return granularity.name().toLowerCase(Locale.ROOT); }","preventionTips":["Only use released enum constants","Keep switch statements over enums exhaustive when adding constants","Run exhaustive-switch lint checks on enum switches"],"tags":["enum","delete","internal","exhaustive-switch"],"backgroundTag":"invalid-enum-value","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}