apache/iceberg · error · UnsupportedOperationException

Cannot modify ManifestEntryWrapper wrapper via set

Error message

Cannot modify ManifestEntryWrapper wrapper via set

What it means

V2Metadata.ManifestEntryWrapper is a read-only StructLike view over a V2 ManifestEntry. Entries (status, sequence numbers, data file) are immutable metadata; set(pos, value) intentionally throws UnsupportedOperationException to prevent in-place mutation that would corrupt snapshot metadata.

Solutions

  1. Build a new ManifestEntry with the desired status/sequences/file instead of mutating the wrapper
  2. Copy wrapped fields into a fresh Record and modify the copy
  3. Use ManifestWriter APIs to write updated entries rather than editing existing structs

Example fix

// before
entryWrapper.set(3, fileSequenceNumber);
// after
ManifestEntry updated = new ManifestEntry(
    Status.EXISTING, snapshotId, dataSequenceNumber, fileSequenceNumber, file);
Defensive patterns

Strategy: validation

Validate before calling

if (entry instanceof V2Metadata.ManifestEntryWrapper) { throw new IllegalStateException("V2 ManifestEntryWrapper is read-only; build a new ManifestEntry"); }

Type guard

boolean isReadOnlyV2Entry(Object s) { return s instanceof V2Metadata.ManifestEntryWrapper; }

Try / catch

try { entryWrapper.set(pos, value); } catch (UnsupportedOperationException e) { throw new IllegalStateException("construct a new ManifestEntry instead", e); }

Prevention

When it happens

Trigger: Calling set(pos, value) on V2Metadata.ManifestEntryWrapper.wrap(entry), e.g. from code updating entry status or sequence numbers directly during rewrite/expire operations.

Common situations: Custom rewrite/compaction jobs mutating entry fields in place; frameworks treating StructLike views as mutable 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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/244da37b29feb88f. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/apache/iceberg/V2Metadata.java:306

    ManifestEntryWrapper(Long commitSnapshotId) {
      this.size = entrySchema(Types.StructType.of()).columns().size();
      this.commitSnapshotId = commitSnapshotId;
      this.fileWrapper = new DataFileWrapper<>();
    }

    public ManifestEntryWrapper<F> wrap(ManifestEntry<F> entry) {
      this.wrapped = entry;
      return this;
    }

    @Override
    public int size() {
      return size;
    }

    @Override
    public <T> void set(int pos, T value) {
      throw new UnsupportedOperationException("Cannot modify ManifestEntryWrapper 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.status().id();
        case 1:
          return wrapped.snapshotId();
        case 2:
          if (wrapped.dataSequenceNumber() == null) {
            // if the entry's data sequence number is null,
            // then it will inherit the sequence number of the current commit.
            // to validate that this is correct, check that the snapshot id is either null (will

View on GitHub (pinned to 86d9c8fc54)