{"record":{"id":"b93f2270242fa44f","repo":"apache/iceberg","slug":"cannot-set-value-b93f22","errorCode":null,"errorMessage":"Cannot set value","messagePattern":"Cannot set value","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/util/PartitionMap.java","lineNumber":254,"sourceCode":"    public int hashCode() {\n      return Objects.hash(specId, structAndValue);\n    }\n\n    @Override\n    public boolean equals(Object other) {\n      if (this == other) {\n        return true;\n      } else if (other == null || getClass() != other.getClass()) {\n        return false;\n      }\n\n      PartitionEntry<?> that = (PartitionEntry<?>) other;\n      return specId == that.specId && Objects.equals(structAndValue, that.structAndValue);\n    }\n\n    @Override\n    public V setValue(V newValue) {\n      throw new UnsupportedOperationException(\"Cannot set value\");\n    }\n  }\n}\n","sourceCodeStart":236,"sourceCodeEnd":258,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/util/PartitionMap.java#L236-L258","documentation":"PartitionEntry is an immutable map entry: setValue is explicitly unsupported because partition entries must not be mutated once constructed. Any call throws UnsupportedOperationException with this message.","triggerScenarios":"Calling setValue(v) on an Entry obtained from a PartitionMap's entrySet, e.g. generic map-mutation code.","commonSituations":"Generic code that rewrites map values in-place while iterating entrySet; adaptation of HashMap-style logic to PartitionMap.","solutions":["Don't mutate entries; remove and re-insert a new value via the map API instead","Rebuild the map with new values if mutation is needed","Use the PartitionMap's put to replace values"],"exampleFix":"// before\nfor (Entry<Pair<Integer, StructLike>, V> e : map.entrySet()) e.setValue(v);\n// after\nmap.put(e.getKey(), v); // or rebuild map with updated values","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isMutableEntry(Entry<?, ?> e) { return !(e instanceof PartitionEntry); }","tryCatchPattern":"try { entry.setValue(v); } catch (UnsupportedOperationException e) { map.put(entry.getKey(), v); }","preventionTips":["Treat PartitionEntry as immutable","Replace values via map.put rather than entry mutation","Copy entries into a HashMap if in-place edits are required"],"tags":["partitionmap","immutable","unsupported"],"backgroundTag":"unsupported-operation","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"}