apache/iceberg · error · UnsupportedOperationException
Cannot modify ManifestFileWrapper wrapper via set
Error message
Cannot modify ManifestFileWrapper wrapper via set
What it means
V2Metadata.ManifestFileWrapper is a read-only StructLike view over a V2 ManifestFile. Manifest files are immutable metadata; set(pos, value) deliberately throws UnsupportedOperationException so wrapped manifest-list records cannot be altered in place.
Solutions
- Construct a new ManifestFile/Record instead of mutating the wrapper
- Copy fields out with get(pos) into your own record and modify the copy
- Ensure custom writers serialize the ManifestFile itself, not the read-only wrapper
Example fix
// before wrapper.set(12, partitionsField); // after Record copy = GenericRecord.create(MANIFEST_LIST_SCHEMA.asStruct()).copy(wrapper); copy.set(12, partitionsField);
Defensive patterns
Strategy: validation
Validate before calling
if (wrapper instanceof V2Metadata.ManifestFileWrapper) { throw new IllegalStateException("read-only wrapper; copy before modifying"); } Type guard
boolean isReadOnlyManifest(Object s) { return s instanceof V2Metadata.ManifestFileWrapper; } Try / catch
try { wrapper.set(pos, value); } catch (UnsupportedOperationException e) { Record copy = GenericRecord.create(MANIFEST_LIST_SCHEMA.asStruct()).copy(wrapper); copy.set(pos, value); } Prevention
- Treat V2 metadata wrappers as immutable like V1
- Copy to GenericRecord for any field mutation
- Serialize the ManifestFile, not the wrapper, in writers
When it happens
Trigger: Calling set(pos, value) on V2Metadata.ManifestFileWrapper.wrap(manifestFile), e.g. from generic writers or mutation-style StructLike code.
Common situations: Custom catalog/writer code reusing mutable records across manifest files; frameworks that assume all StructLike views are writable.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot modify DataFileWrapper wrapper via set
- Cannot modify ManifestEntryWrapper wrapper via set
- Cannot modify ManifestEntryWrapper wrapper via set
- Cannot modify ManifestFileWrapper wrapper via set
- Backup table name cannot be specified
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/0e14798ee6deba66.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/V2Metadata.java:79
ManifestFileWrapper(long commitSnapshotId, long sequenceNumber) {
this.commitSnapshotId = commitSnapshotId;
this.sequenceNumber = sequenceNumber;
}
public ManifestFile wrap(ManifestFile file) {
this.wrapped = file;
return this;
}
@Override
public int size() {
return MANIFEST_LIST_SCHEMA.columns().size();
}
@Override
public <T> void set(int pos, T value) {
throw new UnsupportedOperationException("Cannot modify ManifestFileWrapper wrapper via set");
}
@Override
public <T> T get(int pos, Class<T> javaClass) {
return javaClass.cast(get(pos));
}
private Object get(int pos) {
switch (pos) {
case 0:
return wrapped.path();
case 1:
return wrapped.length();
case 2:
return wrapped.partitionSpecId();
case 3:
checkContentType(wrapped.content());
return wrapped.content().id();View on GitHub (pinned to 86d9c8fc54)