{"record":{"id":"28262c7a0fbe6917","repo":"apache/iceberg","slug":"cannot-write-manifest-for-table-version-s","errorCode":null,"errorMessage":"Cannot write manifest for table version: %s","messagePattern":"Cannot write manifest for table version: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/ManifestFiles.java","lineNumber":284,"sourceCode":"      int formatVersion,\n      PartitionSpec spec,\n      EncryptedOutputFile encryptedOutputFile,\n      Long snapshotId,\n      Long firstRowId,\n      Map<String, String> writerProperties) {\n    switch (formatVersion) {\n      case 1:\n        return new ManifestWriter.V1Writer(spec, encryptedOutputFile, snapshotId, writerProperties);\n      case 2:\n        return new ManifestWriter.V2Writer(spec, encryptedOutputFile, snapshotId, writerProperties);\n      case 3:\n        return new ManifestWriter.V3Writer(\n            spec, encryptedOutputFile, snapshotId, firstRowId, writerProperties);\n      case 4:\n        return new ManifestWriter.V4Writer(\n            spec, encryptedOutputFile, snapshotId, firstRowId, writerProperties);\n    }\n    throw new UnsupportedOperationException(\n        \"Cannot write manifest for table version: \" + formatVersion);\n  }\n\n  /**\n   * Returns a new {@link ManifestReader} for a {@link ManifestFile}.\n   *\n   * @param manifest a {@link ManifestFile}\n   * @param io a {@link FileIO}\n   * @param specsById a Map from spec ID to partition spec\n   * @return a {@link ManifestReader}\n   */\n  public static ManifestReader<DeleteFile> readDeleteManifest(\n      ManifestFile manifest, FileIO io, Map<Integer, PartitionSpec> specsById) {\n    Preconditions.checkArgument(\n        manifest.content() == ManifestContent.DELETES,\n        \"Cannot read a data manifest with a DeleteManifestReader: %s\",\n        manifest);\n    InputFile file = newInputFile(io, manifest);","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/ManifestFiles.java#L266-L302","documentation":"ManifestFiles.newWriter only supports manifest writers for table format versions 1 through 4 (via a switch); any other formatVersion falls through to this UnsupportedOperationException. It guards against writing manifests for table versions the library cannot emit.","triggerScenarios":"Calling ManifestFiles.write or newWriter with a formatVersion outside 1-4, e.g., 0 or 5.","commonSituations":"Reading a table written by a newer Iceberg release supporting a higher format version with an older client; constructing writers with a hand-set formatVersion; corrupted metadata carrying an out-of-range version.","solutions":["Upgrade the Iceberg library so it supports the table's format version","Pass formatVersion 1-4 (matching the table's format-version property) when creating writers manually","Do not mix older clients with tables using newer format versions"],"exampleFix":"// before\nManifestFiles.write(5, spec, outputFile, snapshotId);\n// after\nManifestFiles.write(2, spec, outputFile, snapshotId);","handlingStrategy":"validation","validationCode":"int fv = table.ops().current().formatVersion();\nif (fv < 1 || fv > 4) {\n  throw new IllegalStateException(\"Unsupported format version for manifest write: \" + fv);\n}","typeGuard":null,"tryCatchPattern":"try {\n  ManifestFiles.write(formatVersion, spec, outputFile, snapshotId);\n} catch (UnsupportedOperationException e) {\n  LOG.error(\"Format version {} not supported by this Iceberg build\", formatVersion, e);\n}","preventionTips":["Upgrade the Iceberg client to match tables using newer format versions","Never hardcode formatVersion; read it from table metadata","Pin client versions when sharing tables across jobs"],"tags":["java","unsupported-operation","format-version"],"backgroundTag":"unsupported-operation","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"}