{"record":{"id":"957adca722f0b62e","repo":"apache/iceberg","slug":"invalid-distribution-mode-s","errorCode":null,"errorMessage":"Invalid distribution mode: %s","messagePattern":"Invalid distribution mode: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/DistributionMode.java","lineNumber":59,"sourceCode":"  HASH(\"hash\"),\n  RANGE(\"range\");\n\n  private final String modeName;\n\n  DistributionMode(String modeName) {\n    this.modeName = modeName;\n  }\n\n  public String modeName() {\n    return modeName;\n  }\n\n  public static DistributionMode fromName(String modeName) {\n    Preconditions.checkArgument(null != modeName, \"Invalid distribution mode: null\");\n    try {\n      return DistributionMode.valueOf(modeName.toUpperCase(Locale.ROOT));\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(String.format(\"Invalid distribution mode: %s\", modeName));\n    }\n  }\n}\n","sourceCodeStart":41,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/DistributionMode.java#L41-L63","documentation":"DistributionMode.fromName maps a string (typically from the write distribution mode table property) to the DistributionMode enum, case-insensitively. Unknown names and null both produce an IllegalArgumentException — null with message 'Invalid distribution mode: null', unknown values with 'Invalid distribution mode: <name>'.","triggerScenarios":"Setting write.distribution-mode (or engine equivalent) to a value other than none|hash|range (any case), e.g. 'None', 'key', 'partition', 'HASHING', or leaving a null value where a mode string is required.","commonSituations":"Typos in table properties; copying configs between engines with different valid values (e.g. Spark's 'fanout' style values); programmatic config where the property is absent so null is passed.","solutions":["Set the property to one of: none, hash, or range (case-insensitive).","Null-check/validate the config string before calling fromName, or use DistributionMode.fromName only after supplying a default.","Check the engine's accepted distribution mode values in docs for your Iceberg version; newer versions may add modes, but this parser only accepts enum names.","Fix the typo in the table property (SHOW TBLPROPERTIES / DESCRIBE TABLE to inspect)."],"exampleFix":"// before\ntbl.setProperty(\"write.distribution-mode\", \"partition\");\n\n// after\ntbl.setProperty(\"write.distribution-mode\", \"hash\");","handlingStrategy":"validation","validationCode":"String mode = properties.get(\"write.distribution-mode\");\nSet<String> allowed = Set.of(\"none\", \"hash\", \"range\");\nif (mode != null && !allowed.contains(mode.toLowerCase(Locale.ROOT))) {\n  throw new IllegalArgumentException(\"write.distribution-mode must be none|hash|range, got: \" + mode);\n}","typeGuard":null,"tryCatchPattern":"DistributionMode dm;\ntry {\n  dm = DistributionMode.fromName(mode);\n} catch (IllegalArgumentException e) {\n  dm = DistributionMode.NONE; // or surface config error to user\n}","preventionTips":["Only set write.distribution-mode to none/hash/range.","Normalize case before passing user input to fromName.","Default to a known mode when the property is absent to avoid null.","Validate table properties at write time with a config linter."],"tags":["enum","configuration","distribution-mode","validation"],"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-14T11:17:12.474Z"}