{"record":{"id":"4bce9a94d97fc665","repo":"apache/iceberg","slug":"invalid-file-format-s","errorCode":null,"errorMessage":"Invalid file format: %s","messagePattern":"Invalid file format: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/FileFormat.java","lineNumber":83,"sourceCode":"    for (FileFormat format : VALUES) {\n      int extStart = filename.length() - format.ext.length();\n      if (extStart > 0\n          && Comparators.charSequences()\n                  .compare(format.ext, filename.subSequence(extStart, filename.length()))\n              == 0) {\n        return format;\n      }\n    }\n\n    return null;\n  }\n\n  public static FileFormat fromString(String fileFormat) {\n    Preconditions.checkArgument(null != fileFormat, \"Invalid file format: null\");\n    try {\n      return FileFormat.valueOf(fileFormat.toUpperCase(Locale.ROOT));\n    } catch (IllegalArgumentException e) {\n      throw new IllegalArgumentException(String.format(\"Invalid file format: %s\", fileFormat), e);\n    }\n  }\n}\n","sourceCodeStart":65,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/FileFormat.java#L65-L87","documentation":"FileFormat.fromString parses a string like \"parquet\" or \"avro\" into the FileFormat enum. It throws IllegalArgumentException when the string is null or does not match any known format name (case-insensitive, via Locale.ROOT upper-casing and valueOf).","triggerScenarios":"Passing an unrecognized or null format string, e.g. TableProperties default file format set to \"orc\" in a build without ORC, a typo like \"paruqet\", or an empty string read from configuration.","commonSituations":"Typos in write.format.default / spark.sql.iceberg table properties; config files with trailing whitespace or quoted values; using a format module (ORC) that isn't on the classpath so its constant never registered (pre-enum-registration code) or format not part of the enum.","solutions":["Correct the format string to one of the supported enum names: avro, orc, parquet","Trim/lowercase and validate the configuration value before calling fromString","Catch IllegalArgumentException and fall back to a known-good default format"],"exampleFix":"// before\nFileFormat fmt = FileFormat.fromString(config.get(\"format\"));\n// after\nString raw = config.get(\"format\");\nif (raw == null || !raw.matches(\"(?i)avro|orc|parquet\")) {\n  raw = \"parquet\";\n}\nFileFormat fmt = FileFormat.fromString(raw.trim());","handlingStrategy":"validation","validationCode":"boolean isValidFormat(String s) {\n  return s != null && java.util.Arrays.stream(FileFormat.values())\n      .anyMatch(f -> f.name().equalsIgnoreCase(s.trim()));\n}","typeGuard":null,"tryCatchPattern":"try {\n  format = FileFormat.fromString(raw);\n} catch (IllegalArgumentException e) {\n  format = FileFormat.PARQUET; // default\n}","preventionTips":["Validate format config values against FileFormat.values() at startup","Trim and normalize case before parsing","Use the FileFormat enum constant directly in code instead of strings"],"tags":["java","enum","configuration"],"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-14T16:17:12.679Z"}