{"record":{"id":"d175515cc2e1e3ee","repo":"apache/iceberg","slug":"cannot-unset-reserved-property-s-d17551","errorCode":null,"errorMessage":"Cannot unset reserved property: '%s'","messagePattern":"Cannot unset reserved property: '(.+?)'","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java","lineNumber":730,"sourceCode":"            updateViewProperties.remove(remove.property());\n          }\n        }\n\n        updateViewProperties.commit();\n\n        return new SparkView(catalogName, view);\n      } catch (org.apache.iceberg.exceptions.NoSuchViewException e) {\n        throw new NoSuchViewException(ident);\n      }\n    }\n\n    throw new UnsupportedOperationException(\n        \"Altering a view is not supported by catalog: \" + catalogName);\n  }\n\n  private static void verifyNonReservedProperty(String property, String errorMsg) {\n    if (SparkView.RESERVED_PROPERTIES.contains(property)) {\n      throw new UnsupportedOperationException(String.format(errorMsg, property));\n    }\n  }\n\n  private static void verifyNonReservedPropertyIsUnset(String property) {\n    verifyNonReservedProperty(property, \"Cannot unset reserved property: '%s'\");\n  }\n\n  private static void verifyNonReservedPropertyIsSet(String property) {\n    verifyNonReservedProperty(property, \"Cannot set reserved property: '%s'\");\n  }\n\n  @Override\n  public boolean dropView(Identifier ident) {\n    if (null != asViewCatalog) {\n      return asViewCatalog.dropView(buildIdentifier(ident));\n    }\n\n    return false;","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java#L712-L748","documentation":"SparkView defines reserved properties that are managed by Iceberg/Spark and cannot be removed by users. verifyNonReservedPropertyIsUnset() rejects a RemoveProperty change whose key is in SparkView.RESERVED_PROPERTIES, throwing UnsupportedOperationException with 'Cannot unset reserved property'. Setting a reserved key is rejected by the sibling check with a similar message.","triggerScenarios":"Calling SparkCatalog.alterView (or ALTER VIEW ... UNSET TBLPROPERTIES) with a property name contained in SparkView.RESERVED_PROPERTIES (e.g. 'provider', 'format', 'location' style reserved keys).","commonSituations":"Copy-pasting UNSET TBLPROPERTIES statements meant for tables; scripts that blindly unset all properties including internal ones; attempting to clear metadata Iceberg computes itself.","solutions":["Remove the reserved key from the UNSET/RemoveProperty list and only unset user-defined properties","Read the reserved property instead of trying to change it if you need its value — it is derived metadata","Filter the property list programmatically before calling alterView"],"exampleFix":"// before\nviewCatalog.alterView(ident, ViewChange.removeProperty(\"provider\"));\n// after\nif (!SparkView.RESERVED_PROPERTIES.contains(\"owner\")) {\n  viewCatalog.alterView(ident, ViewChange.removeProperty(\"owner\"));\n}","handlingStrategy":"validation","validationCode":"// Check against reserved properties before altering\njava.util.Set<String> reserved = org.apache.iceberg.spark.SparkView.RESERVED_PROPERTIES;\njava.util.List<String> keys = changes.stream()\n    .filter(c -> c instanceof ViewChange.RemoveProperty)\n    .map(c -> ((ViewChange.RemoveProperty) c).property())\n    .toList();\nif (keys.stream().anyMatch(reserved::contains)) {\n  throw new IllegalArgumentException(\"Reserved properties cannot be unset: \" + keys);\n}","typeGuard":"boolean isReserved(String property) {\n  return org.apache.iceberg.spark.SparkView.RESERVED_PROPERTIES.contains(property);\n}","tryCatchPattern":"try {\n  catalog.alterView(ident, ViewChange.removeProperty(key));\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Cannot unset reserved property\")) {\n    logger.warn(\"Skipping reserved property {}\", key);\n  }\n}","preventionTips":["Filter out SparkView.RESERVED_PROPERTIES before building ViewChange lists","Treat reserved keys as read-only derived metadata","When bulk-unsetting properties, intersect the key set with the view's own user properties only"],"tags":["spark","view","reserved-properties","unsupported-operation"],"backgroundTag":"invalid-argument-value","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"}