{"record":{"id":"1efa3a2a50a5041d","repo":"apache/iceberg","slug":"cannot-create-namespace-s-s","errorCode":null,"errorMessage":"Cannot create namespace '%s': %s","messagePattern":"Cannot create namespace '(.+?)': (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":251,"sourceCode":"        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);\n    }\n  }\n\n  public List<Namespace> listNamespaces(Namespace namespace) throws NoSuchNamespaceException {\n    try {\n      String filter = \"entry.contentType == 'NAMESPACE' && \";\n      if (namespace.isEmpty()) {","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L233-L269","documentation":"This is the catch-all in NessieIcebergClient.createNamespace: any NessieConflictException that isn't KEY_EXISTS or NAMESPACE_ABSENT (or other unhandled commit conflicts) is wrapped in a RuntimeException formatted as 'Cannot create namespace %s: <conflict message>'. It surfaces server-side conflict details without a typed Iceberg exception.","triggerScenarios":"Calling createNamespace while the Nessie server reports an unexpected conflict type — e.g. concurrent commits to the same branch producing a generic Conflict, ref hash changed (update on stale ref), or server-side validation errors other than KEY_EXISTS/NAMESPACE_ABSENT.","commonSituations":"Concurrent writers committing namespaces/tables to the same branch simultaneously; branch was force-updated between client reads and the commit; using a detached/tag ref that disallows the operation.","solutions":["Retry the createNamespace after refreshing the catalog/client so it commits against the latest ref hash.","Serialize namespace creation (avoid multiple processes creating the same namespace concurrently), or tolerate a RuntimeException as 'someone else created it' and verify with namespaceExists.","Inspect the wrapped message for the underlying Nessie conflict and fix per its cause (e.g. switch to the correct branch)."],"exampleFix":"// before\ncatalog.createNamespace(ns); // RuntimeException on conflict\n// after\ntry {\n  catalog.createNamespace(ns);\n} catch (RuntimeException e) {\n  if (catalog.namespaceExists(ns)) {\n    // created concurrently; proceed\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"retry","validationCode":"// minimize conflict windows: refresh ref state before committing\napi.reference().refName(branch).get(); // confirm current hash before createNamespace","typeGuard":null,"tryCatchPattern":"try {\n  catalog.createNamespace(ns);\n} catch (RuntimeException e) {\n  if (catalog.namespaceExists(ns)) {\n    // concurrent creation; treat as success\n  } else {\n    throw e;\n  }\n}","preventionTips":["Avoid concurrent namespace creation on the same branch","Re-create the catalog (fresh client/ref hash) before retrying after conflicts","Treat generic conflicts as 'maybe created concurrently' and verify with namespaceExists"],"tags":["nessie","namespace","conflict","concurrency","runtime"],"backgroundTag":"conflicting-writes","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"}