{"record":{"id":"a9641189b92daf0c","repo":"apache/iceberg","slug":"failed-to-rewrite-the-manifest-list-file","errorCode":null,"errorMessage":"Failed to rewrite the manifest list file {}","messagePattern":"Failed to rewrite the manifest list file (.+?)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/RewriteTablePathUtil.java","lineNumber":345,"sourceCode":"            snapshot.firstRowId())) {\n\n      for (ManifestFile file : manifestFiles) {\n        ManifestFile newFile = file.copy();\n        ((StructLike) newFile).set(0, newPath(newFile.path(), sourcePrefix, targetPrefix));\n        ((StructLike) newFile)\n            .set(1, rewrittenManifestLengths.getOrDefault(file.path(), file.length()));\n        writer.add(newFile);\n\n        if (rewrittenManifestLengths.containsKey(file.path())) {\n          result.toRewrite().add(file);\n          result\n              .copyPlan()\n              .add(Pair.of(stagingPath(file.path(), sourcePrefix, stagingDir), newFile.path()));\n        }\n      }\n      return result;\n    } catch (IOException e) {\n      throw new UncheckedIOException(\n          \"Failed to rewrite the manifest list file \" + snapshot.manifestListLocation(), e);\n    }\n  }\n\n  private static List<ManifestFile> manifestFilesInSnapshot(FileIO io, Snapshot snapshot) {\n    try {\n      return snapshot.allManifests(io);\n    } catch (RuntimeIOException e) {\n      LOG.warn(\"Failed to read manifest list {}\", snapshot.manifestListLocation(), e);\n      return ImmutableList.of();\n    }\n  }\n\n  /**\n   * Rewrite a data manifest, replacing path references.\n   *\n   * @param manifestFile source manifest file to rewrite\n   * @param snapshotIds snapshot ids for filtering returned data manifest entries","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/RewriteTablePathUtil.java#L327-L363","documentation":"RewriteTablePathUtil.rewriteManifestList copies a snapshot's manifest list while rewriting paths for table relocation/staging (e.g., snapshot copy or table migration). An IOException during writing the rewritten manifest list is rethrown as UncheckedIOException including the manifest list location. It indicates the new manifest list file could not be produced.","triggerScenarios":"Calling rewriteManifestList (via RewriteTablePathUtil rewrite/copy utilities, e.g. table staging or relocation) when writing the manifest list to the staging/target location fails with IOException.","commonSituations":"Unwritable staging directory; disk full; object-store permission errors on the target prefix; interrupted network writes during table relocation.","solutions":["Check write permissions and free space on the staging/target location","Verify the target FileIO/prefix configuration (credentials, endpoint) is correct and retry","Re-run the rewrite from a clean staging directory, removing partial output files"],"exampleFix":"// before\nRewriteTablePathUtil.rewriteManifestList(snapshot, io, sourcePrefix, stagingDir, specsById);\n// after\ntry {\n  RewriteTablePathUtil.rewriteManifestList(snapshot, io, sourcePrefix, stagingDir, specsById);\n} catch (UncheckedIOException e) {\n  LOG.error(\"Manifest list rewrite failed for {}: {}\", snapshot.manifestListLocation(), e.getMessage());\n  // verify staging dir writability, then retry\n}","handlingStrategy":"try-catch","validationCode":"File stagingDirFile = new File(stagingDir);\nPreconditions.checkArgument(stagingDirFile.canWrite() && stagingDirFile.getUsableSpace() > 0,\n    \"Staging dir not writable or full: \" + stagingDir);","typeGuard":null,"tryCatchPattern":"try {\n  RewriteTablePathUtil.rewriteManifestList(snapshot, io, sourcePrefix, stagingDir, specsById);\n} catch (UncheckedIOException e) {\n  // check staging dir writability/space and target prefix permissions, clean partials, retry\n}","preventionTips":["Pre-flight check staging directory writability and free space","Verify target-prefix credentials before relocation","Clean partial outputs before re-running","Run relocations with sufficient disk headroom"],"tags":["iceberg","io","table-relocation"],"backgroundTag":"file-write-failed","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"}