{"record":{"id":"724399ece028b7c3","repo":"apache/iceberg","slug":"cannot-modify-datafilewrapper-wrapper-via-set-724399","errorCode":null,"errorMessage":"Cannot modify DataFileWrapper wrapper via set","messagePattern":"Cannot modify DataFileWrapper wrapper via set","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/V2Metadata.java","lineNumber":421,"sourceCode":"\n    DataFileWrapper() {\n      this.size = fileType(Types.StructType.of()).fields().size();\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    DataFileWrapper<F> wrap(ContentFile<?> file) {\n      this.wrapped = (ContentFile<F>) file;\n      return this;\n    }\n\n    @Override\n    public int size() {\n      return size;\n    }\n\n    @Override\n    public <T> void set(int pos, T value) {\n      throw new UnsupportedOperationException(\"Cannot modify DataFileWrapper wrapper via set\");\n    }\n\n    @Override\n    public <T> T get(int pos, Class<T> javaClass) {\n      return javaClass.cast(get(pos));\n    }\n\n    private Object get(int pos) {\n      switch (pos) {\n        case 0:\n          checkContentType(wrapped.content());\n          return wrapped.content().id();\n        case 1:\n          return wrapped.location();\n        case 2:\n          return wrapped.format() != null ? wrapped.format().toString() : null;\n        case 3:\n          return wrapped.partition();","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/V2Metadata.java#L403-L439","documentation":"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.","triggerScenarios":"Thrown at core/src/main/java/org/apache/iceberg/V2Metadata.java:421 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Never mutate files through the wrapper; construct new file metadata instead","Use the wrapped ContentFile for reads and build replacement objects for writes","Copy data into a mutable struct before modifying if mutation is truly needed"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}