{"record":{"id":"50516de940593dcf","repo":"apache/iceberg","slug":"cannot-create-namespace-s-parent-namespace-s","errorCode":null,"errorMessage":"Cannot create namespace '%s': parent namespace '%s' does not exist","messagePattern":"Cannot create namespace '(.+?)': parent namespace '(.+?)' does not exist","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":244,"sourceCode":"      Content existing = api.getContent().reference(getReference()).key(key).get().get(key);\n      if (existing != null) {\n        throw namespaceAlreadyExists(key, existing, null);\n      }\n      try {\n        commitRetry(\"create namespace \" + key, Operation.Put.of(key, content));\n      } catch (NessieReferenceConflictException e) {\n        Optional<Conflict> conflict =\n            NessieUtil.extractSingleConflict(\n                e,\n                EnumSet.of(\n                    Conflict.ConflictType.KEY_EXISTS, Conflict.ConflictType.NAMESPACE_ABSENT));\n        if (conflict.isPresent()) {\n          switch (conflict.get().conflictType()) {\n            case KEY_EXISTS:\n              Content conflicting = withReference(api.getContent()).key(key).get().get(key);\n              throw namespaceAlreadyExists(key, conflicting, e);\n            case NAMESPACE_ABSENT:\n              throw new NoSuchNamespaceException(\n                  e,\n                  \"Cannot create namespace '%s': parent namespace '%s' does not exist\",\n                  namespace,\n                  conflict.get().key());\n          }\n        }\n        throw new RuntimeException(\n            String.format(\"Cannot create namespace '%s': %s\", namespace, e.getMessage()));\n      }\n    } catch (NessieNotFoundException e) {\n      throw new UncheckedIOException(\n          String.format(\n              \"Cannot create namespace '%s': ref '%s' is no longer valid.\",\n              namespace, getRef().getName()),\n          e);\n    } catch (BaseNessieClientServerException e) {\n      throw new UncheckedIOException(\n          String.format(\"Cannot create namespace '%s': %s\", namespace, e.getMessage()), e);","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L226-L262","documentation":"createNamespace commits a namespace (as a content key) to Nessie. When the Nessie server responds with a NAMESPACE_ABSENT conflict, the client translates it into NoSuchNamespaceException saying the parent namespace doesn't exist — you cannot create a nested namespace whose parent path was never created.","triggerScenarios":"Calling NessieCatalog.createNamespace for a multi-level namespace like 'a.b.c' when 'a.b' (or 'a') has not been created yet; Nessie commit fails with Conflict/NAMESPACE_ABSENT and the client wraps it.","commonSituations":"Creating deep namespaces in one call instead of level by level; parent namespace deleted concurrently by another process; assuming Iceberg auto-creates parent namespaces on Nessie-backed catalogs.","solutions":["Create parent namespaces first, in order: createNamespace(Namespace.of(\"a\")), then Namespace.of(\"a\",\"b\"), then the target.","Or use a flat (single-level) namespace if hierarchical scoping isn't required.","If the parent was deleted concurrently, re-create it before retrying the child namespace creation."],"exampleFix":"// before\ncatalog.createNamespace(Namespace.of(\"a\", \"b\", \"c\")); // NoSuchNamespaceException\n// after\ncatalog.createNamespace(Namespace.of(\"a\"));\ncatalog.createNamespace(Namespace.of(\"a\", \"b\"));\ncatalog.createNamespace(Namespace.of(\"a\", \"b\", \"c\"));","handlingStrategy":"validation","validationCode":"// ensure every parent level exists before creating a nested namespace\nNamespace ns = Namespace.of(\"a\", \"b\", \"c\");\nfor (int i = 1; i <= ns.levels().length; i++) {\n  Namespace parent = Namespace.of(Arrays.copyOf(ns.levels(), i));\n  if (!catalog.namespaceExists(parent)) catalog.createNamespace(parent);\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.createNamespace(ns);\n} catch (NoSuchNamespaceException e) {\n  // create parents first, then retry\n  createParentsInOrder(ns);\n  catalog.createNamespace(ns);\n}","preventionTips":["Create namespaces level by level for multi-level names","Remember Nessie does not auto-create parent namespaces","Check namespaceExists before creating to keep idempotency"],"tags":["nessie","namespace","hierarchy","conflict"],"backgroundTag":"parent-issue-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}