apache/iceberg · error · UnsupportedOperationException
Cannot modify ManifestFileWrapper wrapper via set
Error message
Cannot modify ManifestFileWrapper wrapper via set
What it means
ManifestFileWrapper is a read-only StructLike view over a ManifestFile in V1Metadata. Its set(pos, value) is intentionally unimplemented because manifests are immutable metadata; mutating a wrapped manifest file would corrupt table metadata. The library throws UnsupportedOperationException to enforce read-only access.
Solutions
- Do not call set on the wrapper; construct a new ManifestFile/Record instead of mutating the wrapped one
- If you need a mutable record, copy fields via get(pos) into your own Record and modify that
- Check that custom writers use ManifestFile itself, not the read-only wrapper, when serializing
Example fix
// before structLike.set(0, newPath); // after Record copy = GenericRecord.create(MANIFEST_LIST_SCHEMA.asStruct()).copy(structLike); copy.set(0, newPath);
Defensive patterns
Strategy: validation
Validate before calling
if (wrapper instanceof V1Metadata.ManifestFileWrapper) { throw new IllegalStateException("read-only wrapper; copy fields instead of set()"); } Type guard
boolean isReadOnlyWrapper(Object s) { return s instanceof V1Metadata.ManifestFileWrapper || s instanceof V1Metadata.ManifestEntryWrapper || s instanceof V1Metadata.DataFileWrapper; } Try / catch
try { structLike.set(pos, value); } catch (UnsupportedOperationException e) { Record copy = GenericRecord.create(schema.asStruct()).copy(structLike); copy.set(pos, value); } Prevention
- Treat all Iceberg metadata StructLike wrappers as read-only
- Copy into a GenericRecord before modifying metadata structs
- Never reuse manifest wrappers as mutable write buffers
When it happens
Trigger: Calling set(pos, value) on a ManifestFileWrapper obtained via V1Metadata.ManifestFileWrapper.wrap(manifestFile), e.g. when writing manifests via a GenericDataWriter or when code treats the StructLike as mutable.
Common situations: Custom catalog or writer code that reuses a mutable StructLike buffer across records and calls set() on manifest-file structs; reflection-based frameworks (Avro/GenericData) attempting in-place mutation of manifest list records.
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/bcd54ccbaffcb31e.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/apache/iceberg/V1Metadata.java:68
* <p>This is used to maintain compatibility with v1 by writing manifest list files with the old
* schema, instead of writing a sequence number into metadata files in v1 tables.
*/
static class ManifestFileWrapper implements ManifestFile, StructLike {
private ManifestFile wrapped = null;
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 path();
case 1:
return length();
case 2:
return partitionSpecId();
case 3:
return snapshotId();
case 4:View on GitHub (pinned to 86d9c8fc54)