apache/iceberg · error · UnsupportedOperationException

Cannot modify DataFileWrapper wrapper via set

Error message

Cannot modify DataFileWrapper wrapper via set

What it means

Guard on V2Metadata.DataFileWrapper.set: this object is a read-only adapter that projects a v1 DataFile's fields into the v2 metadata layout during manifest rewrites. Calling the StructLike set() mutator is intentionally unsupported; the underlying ContentFile is the source of truth and must not be modified through the wrapper.

Solutions

  1. Never mutate files through the wrapper; construct new file metadata instead
  2. Use the wrapped ContentFile for reads and build replacement objects for writes
  3. Copy data into a mutable struct before modifying if mutation is truly needed
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at core/src/main/java/org/apache/iceberg/V2Metadata.java:421 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

    DataFileWrapper() {
      this.size = fileType(Types.StructType.of()).fields().size();
    }

    @SuppressWarnings("unchecked")
    DataFileWrapper<F> wrap(ContentFile<?> file) {
      this.wrapped = (ContentFile<F>) file;
      return this;
    }

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

    @Override
    public <T> void set(int pos, T value) {
      throw new UnsupportedOperationException("Cannot modify DataFileWrapper 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:
          checkContentType(wrapped.content());
          return wrapped.content().id();
        case 1:
          return wrapped.location();
        case 2:
          return wrapped.format() != null ? wrapped.format().toString() : null;
        case 3:
          return wrapped.partition();

View on GitHub (pinned to 86d9c8fc54)