{"record":{"id":"03ee7a5dca26132d","repo":"apache/iceberg","slug":"invalid-namespace-update-cannot-simultaneously-se","errorCode":null,"errorMessage":"Invalid namespace update, cannot simultaneously set and remove keys: %s","messagePattern":"Invalid namespace update, cannot simultaneously set and remove keys: (.+?)","errorType":"validation","errorClass":"UnprocessableEntityException","httpStatus":422,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/rest/requests/UpdateNamespacePropertiesRequest.java","lineNumber":56,"sourceCode":"\n  private List<String> removals;\n  private Map<String, String> updates;\n\n  public UpdateNamespacePropertiesRequest() {\n    // Required for Jackson deserialization.\n  }\n\n  private UpdateNamespacePropertiesRequest(List<String> removals, Map<String, String> updates) {\n    this.removals = removals;\n    this.updates = updates;\n    validate();\n  }\n\n  @Override\n  public void validate() {\n    Set<String> commonKeys = Sets.intersection(updates().keySet(), Sets.newHashSet(removals()));\n    if (!commonKeys.isEmpty()) {\n      throw new UnprocessableEntityException(\n          \"Invalid namespace update, cannot simultaneously set and remove keys: %s\", commonKeys);\n    }\n  }\n\n  public List<String> removals() {\n    return removals == null ? ImmutableList.of() : removals;\n  }\n\n  public Map<String, String> updates() {\n    return updates == null ? ImmutableMap.of() : updates;\n  }\n\n  @Override\n  public String toString() {\n    return MoreObjects.toStringHelper(this)\n        .add(\"removals\", removals)\n        .add(\"updates\", updates)\n        .toString();","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/rest/requests/UpdateNamespacePropertiesRequest.java#L38-L74","documentation":"UpdateNamespacePropertiesRequest.validate() rejects requests whose 'updates' (properties to set) and 'removals' (property names to delete) overlap on the same key. The REST catalog cannot apply both operations to one property at once, so it throws UnprocessableEntityException (HTTP 422) before the request is submitted. This protects servers from ambiguous, order-dependent namespace mutations.","triggerScenarios":"Building an UpdateNamespacePropertiesRequest where the same key appears in both the update map and the removal list, or client code that computes removals from a stale property list while simultaneously setting new values for those keys.","commonSituations":"Automation scripts that both rename and set namespace properties; deserialization of malformed client JSON that lists a key in both fields; race conditions where two tools edit the same namespace property concurrently.","solutions":["Remove the conflicting key from either the updates map or the removals list before building the request","Compute removals as the set difference of current keys minus keys you are updating","Split the change into two sequential requests: first removals, then updates"],"exampleFix":"// before\nrequest = UpdateNamespacePropertiesRequest.builder()\n    .update(\"owner\", \"alice\")\n    .remove(\"owner\")\n    .build();\n// after\nrequest = UpdateNamespacePropertiesRequest.builder()\n    .update(\"owner\", \"alice\")\n    .build();","handlingStrategy":"validation","validationCode":"Set<String> conflicts = Sets.intersection(updates.keySet(), Sets.newHashSet(removals));\nif (!conflicts.isEmpty()) throw new IllegalArgumentException(\"Conflicting keys: \" + conflicts);","typeGuard":null,"tryCatchPattern":"try { request.validate(); catalog.updateNamespaceProperties(ns, request); } catch (UnprocessableEntityException e) { /* split into two requests */ }","preventionTips":["Derive removals from current properties minus keys being updated","Run request.validate() client-side before sending","Never build removals from stale reads while also setting values"],"tags":["rest","namespace","validation","conflict"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}