{"record":{"id":"8b6edbf9ffe71c50","repo":"apache/iceberg","slug":"content-object-with-name-s-is-not-a-namespace","errorCode":null,"errorMessage":"Content object with name '%s' is not a namespace.","messagePattern":"Content object with name '(.+?)' is not a namespace\\.","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":330,"sourceCode":"      }\n      throw new NoSuchNamespaceException(\n          e,\n          \"Cannot list child namespaces from '%s': ref '%s' is no longer valid.\",\n          namespace,\n          getRef().getName());\n    }\n  }\n\n  public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {\n    checkNamespaceIsValid(namespace);\n    getRef().checkMutable();\n    ContentKey key = ContentKey.of(namespace.levels());\n    try {\n      Map<ContentKey, Content> contentMap =\n          api.getContent().reference(getReference()).key(key).get();\n      Content existing = contentMap.get(key);\n      if (existing != null && !existing.getType().equals(Content.Type.NAMESPACE)) {\n        throw new NoSuchNamespaceException(\n            \"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:","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L312-L348","documentation":"dropNamespace looks up the content at the namespace key; if content exists but its type is not NAMESPACE (i.e. it is a table or view), it refuses to drop and throws NoSuchNamespaceException 'Content object with name X is not a namespace.' This prevents deleting a table/view key through the namespace API.","triggerScenarios":"Calling Catalog.dropNamespace(Namespace.of(\"x\")) where 'x' is actually an Iceberg table or view identifier on the current ref.","commonSituations":"Confusing namespace and table hierarchies after renaming; passing a table name to dropNamespace by mistake; a key that previously held a namespace was overwritten by a table.","solutions":["Use catalog.dropTable(TableIdentifier) or dropView for non-namespace content.","Check content type first via catalog.namespaceExists / listNamespaces before dropping.","If the key truly should be a namespace, recreate the namespace and move the table elsewhere."],"exampleFix":"// before\ncatalog.dropNamespace(Namespace.of(\"events\")); // 'events' is a table\n// after\nif (catalog.namespaceExists(Namespace.of(\"events\"))) {\n  catalog.dropNamespace(Namespace.of(\"events\"));\n} else {\n  catalog.dropTable(TableIdentifier.of(\"events\"));\n}","handlingStrategy":"validation","validationCode":"if (catalog.namespaceExists(ns)) {\n  catalog.dropNamespace(ns);\n} else if (catalog.tableExists(TableIdentifier.of(ns.levels()))) {\n  catalog.dropTable(TableIdentifier.of(ns.levels()));\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.dropNamespace(ns);\n} catch (NoSuchNamespaceException e) {\n  if (e.getMessage().contains(\"is not a namespace\")) {\n    catalog.dropTable(TableIdentifier.of(ns.levels()));\n  } else throw e;\n}","preventionTips":["Distinguish namespace vs table keys with namespaceExists/tableExists before dropping.","Don't reuse the same identifier for a table and a namespace.","Centralize drop logic in a helper that dispatches on content type."],"tags":["nessie","namespace","type-mismatch","drop"],"backgroundTag":"type-mismatch","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"}