{"record":{"id":"7251e8935d3f8401","repo":"apache/iceberg","slug":"namespace-s-is-not-empty-7251e8","errorCode":null,"errorMessage":"Namespace '%s' is not empty.","messagePattern":"Namespace '(.+?)' is not empty\\.","errorType":"exception","errorClass":"NamespaceNotEmptyException","httpStatus":409,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":349,"sourceCode":"            \"Content object with name '%s' is not a namespace.\", namespace);\n      }\n      try {\n        commitRetry(\"drop namespace \" + key, Operation.Delete.of(key));\n        return true;\n      } catch (NessieReferenceConflictException e) {\n        Optional<Conflict> conflict =\n            NessieUtil.extractSingleConflict(\n                e,\n                EnumSet.of(\n                    Conflict.ConflictType.KEY_DOES_NOT_EXIST,\n                    Conflict.ConflictType.NAMESPACE_NOT_EMPTY));\n        if (conflict.isPresent()) {\n          Conflict.ConflictType conflictType = conflict.get().conflictType();\n          switch (conflictType) {\n            case KEY_DOES_NOT_EXIST:\n              return false;\n            case NAMESPACE_NOT_EMPTY:\n              throw new NamespaceNotEmptyException(e, \"Namespace '%s' is not empty.\", namespace);\n          }\n        }\n        throw new UncheckedIOException(\n            String.format(\"Cannot drop namespace '%s': %s\", namespace, e.getMessage()), e);\n      }\n    } catch (NessieNotFoundException e) {\n      LOG.error(\n          \"Cannot drop namespace '{}': ref '{}' is no longer valid.\",\n          namespace,\n          getRef().getName(),\n          e);\n    } catch (BaseNessieClientServerException e) {\n      throw new UncheckedIOException(\n          String.format(\"Cannot drop namespace '%s': %s\", namespace, e.getMessage()), e);\n    }\n    return false;\n  }\n","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L331-L367","documentation":"When the drop commit conflicts server-side with NAMESPACE_NOT_EMPTY, the client rethrows as NamespaceNotEmptyException. Nessie enforces that a namespace key cannot be deleted while nested namespaces or tables still live under it.","triggerScenarios":"Calling Catalog.dropNamespace(Namespace.of(\"a\")) while tables/views or child namespaces like 'a.b' or 'a.tbl' still exist under it on the current ref.","commonSituations":"Trying to clean up a parent namespace before migrating its tables; concurrent writers added a table between your check and the drop.","solutions":["Drop or move all tables and views under the namespace first (listTables + dropTable).","Drop child namespaces (deepest first) before the parent.","Re-check after concurrent writers: re-list contents and retry the drop."],"exampleFix":"// before\ncatalog.dropNamespace(Namespace.of(\"a\")); // still contains tables\n// after\nfor (TableIdentifier t : catalog.listTables(Namespace.of(\"a\"))) {\n  catalog.dropTable(t);\n}\ncatalog.dropNamespace(Namespace.of(\"a\"));","handlingStrategy":"validation","validationCode":"boolean empty = catalog.listTables(ns).isEmpty()\n    && catalog.listNamespaces(ns).isEmpty();\nif (!empty) throw new IllegalStateException(\"Namespace not empty: \" + ns);","typeGuard":null,"tryCatchPattern":"try {\n  return catalog.dropNamespace(ns);\n} catch (NamespaceNotEmptyException e) {\n  // drain children deepest-first, then retry\n  return drainAndDrop(ns);\n}","preventionTips":["Always list and drop children (tables, views, sub-namespaces) before the parent.","Treat drop-namespace as a bottom-up cleanup operation.","Re-check emptiness right before dropping in concurrent environments."],"tags":["nessie","namespace","not-empty","conflict"],"backgroundTag":"invalid-state-transition","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"}