{"record":{"id":"b429dde5bf6f77e4","repo":"apache/iceberg","slug":"invalid-codec-name-s","errorCode":null,"errorMessage":"Invalid codec name: %s","messagePattern":"Invalid codec name: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/TableMetadataParser.java","lineNumber":65,"sourceCode":"\npublic class TableMetadataParser {\n\n  public enum Codec {\n    NONE(\"\"),\n    GZIP(\".gz\");\n\n    private final String extension;\n\n    Codec(String extension) {\n      this.extension = extension;\n    }\n\n    public static Codec fromName(String codecName) {\n      Preconditions.checkArgument(codecName != null, \"Codec name is null\");\n      try {\n        return Codec.valueOf(codecName.toUpperCase(Locale.ROOT));\n      } catch (IllegalArgumentException e) {\n        throw new IllegalArgumentException(String.format(\"Invalid codec name: %s\", codecName), e);\n      }\n    }\n\n    public static Codec fromFileName(String fileName) {\n      Preconditions.checkArgument(\n          fileName.contains(\".metadata.json\"), \"%s is not a valid metadata file\", fileName);\n      // we have to be backward-compatible with .metadata.json.gz files\n      if (fileName.endsWith(\".metadata.json.gz\")) {\n        return Codec.GZIP;\n      }\n      String fileNameWithoutSuffix = fileName.substring(0, fileName.lastIndexOf(\".metadata.json\"));\n      if (fileNameWithoutSuffix.endsWith(Codec.GZIP.extension)) {\n        return Codec.GZIP;\n      } else {\n        return Codec.NONE;\n      }\n    }\n  }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/TableMetadataParser.java#L47-L83","documentation":"TableMetadataParser.Codec.fromName parses a codec name (e.g. \"gzip\") by uppercasing it and doing an enum valueOf. Any name that isn't a defined Codec constant fails and is rethrown as IllegalArgumentException with 'Invalid codec name'. This validates the write.metadata.previous-versions-max... actually the metadata compression codec configuration before a metadata file is written.","triggerScenarios":"Calling TableMetadataParser.Codec.fromName(\"GZIP\") with a typo'd or unsupported string, e.g. table property write.metadata.compression-codec set to \"gz\", \"zip\", or \"zstd\" when only NONE/GZIP (or the supported set) exists.","commonSituations":"Config typo in the metadata compression codec property; copying a config from another system (parquet/orc codec names like snappy, zstd) that the metadata codec enum doesn't support; case-sensitive assumptions resolved by the toUpperCase, but abbreviations still fail.","solutions":["Use an exact supported codec name, e.g. \"gzip\" or \"none\", in the configuration","Fix the typo by checking the Codec enum's defined constants","If you need zstd/snappy metadata compression, upgrade to a version whose Codec enum supports it","Pre-validate the configured value against TableMetadataParser.Codec.values() before setting the property"],"exampleFix":"// before\nprops.put(\"write.metadata.compression-codec\", \"gz\");\n// after\nprops.put(\"write.metadata.compression-codec\", \"gzip\");","handlingStrategy":"validation","validationCode":"Set<String> allowed = Arrays.stream(TableMetadataParser.Codec.values())\n    .map(c -> c.name().toLowerCase(Locale.ROOT))\n    .collect(Collectors.toSet());\nif (!allowed.contains(configuredCodec.toLowerCase(Locale.ROOT))) {\n  throw new IllegalArgumentException(\"Codec must be one of \" + allowed);\n}","typeGuard":null,"tryCatchPattern":"try { TableMetadataParser.Codec.fromName(name); }\ncatch (IllegalArgumentException e) {\n  LOG.error(\"Bad write.metadata.compression-codec '{}'; use gzip or none\", name);\n}","preventionTips":["Use full codec names (gzip, none), not parquet-style abbreviations (gz, snappy)","Validate the codec property at startup/configuration load time","Check the Codec enum of your exact Iceberg version — supported values change over releases"],"tags":["codec","configuration","enum","iceberg"],"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"}