{"record":{"id":"33ac2c84cc30559e","repo":"apache/iceberg","slug":"failed-to-validate-replaced-partitions","errorCode":null,"errorMessage":"Failed to validate replaced partitions","messagePattern":"Failed to validate replaced partitions","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/CherryPickOperation.java","lineNumber":248,"sourceCode":"        Iterable<CloseableIterable<DataFile>> addedFileTasks =\n            Iterables.concat(\n                Iterables.transform(\n                    snapshots,\n                    snap ->\n                        Iterables.transform(\n                            manifestsCreatedBy(snap, io),\n                            manifest -> addedDataFiles(manifest, io, meta.specsById()))));\n\n        try (CloseableIterable<DataFile> newFiles =\n            new ParallelIterable<>(addedFileTasks, ThreadPools.getWorkerPool())) {\n          for (DataFile newFile : newFiles) {\n            ValidationException.check(\n                !replacedPartitions.contains(newFile.specId(), newFile.partition()),\n                \"Cannot cherry-pick replace partitions with changed partition: %s\",\n                newFile.partition());\n          }\n        } catch (IOException e) {\n          throw new UncheckedIOException(\"Failed to validate replaced partitions\", e);\n        }\n      }\n    }\n  }\n\n  private static Iterable<ManifestFile> manifestsCreatedBy(Snapshot snapshot, FileIO io) {\n    return Iterables.filter(\n        snapshot.dataManifests(io), m -> Objects.equals(m.snapshotId(), snapshot.snapshotId()));\n  }\n\n  private static CloseableIterable<DataFile> addedDataFiles(\n      ManifestFile manifest, FileIO io, Map<Integer, PartitionSpec> specsById) {\n    CloseableIterable<ManifestEntry<DataFile>> entries =\n        ManifestFiles.read(manifest, io, specsById).entries();\n    CloseableIterable<ManifestEntry<DataFile>> added =\n        CloseableIterable.filter(entries, e -> e.status() == ManifestEntry.Status.ADDED);\n    return CloseableIterable.transform(added, e -> e.file().copy());\n  }","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/CherryPickOperation.java#L230-L266","documentation":"During cherry-pick validation, the manifests of the snapshot being picked are scanned to ensure no replaced partitions had their partition spec/data changed (a full overwrite must be picked into a matching partition layout). An IOException while reading those manifest files is wrapped in this UncheckedIOException.","triggerScenarios":"table.cherryPick(snapshotId) where the snapshot contains overwritten partitions and the manifest files listed in the snapshot cannot be read (missing, corrupt, or unreadable via the configured FileIO).","commonSituations":"Deleted or expired manifests referenced by a retained snapshot; wrong FileIO/credentials so manifest reads fail; corrupted object storage files after partial writes.","solutions":["Check the cause IOException for the real read failure (file-not-found, auth, checksum).","Verify manifests exist and are readable with the configured FileIO and credentials.","Ensure snapshot expiry has not deleted manifests still referenced by the snapshot being picked.","Retry after fixing storage access; the operation is read-only until validation passes."],"exampleFix":"// inspect root cause\ntry {\n  table.cherryPick(snapshotId);\n} catch (UncheckedIOException e) {\n  LOG.error(\"manifest read failed\", e.getCause());\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// pre-check manifest readability\nSnapshot snap = table.snapshot(snapshotId);\nsnap.allManifests(table.io()).forEach(m ->\n    Preconditions.check(table.io().newInputFile(m.path()).exists(), \"missing manifest \" + m.path()));","typeGuard":null,"tryCatchPattern":"try { table.cherryPick(id); } catch (UncheckedIOException e) {\n  LOG.error(\"manifest validation failed\", e.getCause());\n  throw e;\n}","preventionTips":["Verify FileIO credentials and storage access before cherry-pick.","Avoid expiring manifests referenced by snapshots you still plan to pick.","Log e.getCause() to diagnose the true read failure."],"tags":["io","manifest","cherry-pick"],"backgroundTag":"file-read-failed","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"}