{"record":{"id":"30e41622e1a0e1ed","repo":"apache/iceberg","slug":"cannot-list-top-level-namespaces-ref-s-is-no-l","errorCode":null,"errorMessage":"Cannot list top-level namespaces: ref '%s' is no longer valid.","messagePattern":"Cannot list top-level namespaces: ref '(.+?)' is no longer valid\\.","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java","lineNumber":308,"sourceCode":"      }\n      List<ContentKey> entries =\n          withReference(api.getEntries()).filter(filter).stream()\n              .map(EntriesResponse.Entry::getName)\n              .collect(Collectors.toList());\n      if (entries.isEmpty()) {\n        return Collections.emptyList();\n      }\n      GetContentBuilder getContent = withReference(api.getContent());\n      entries.forEach(getContent::key);\n      return getContent.get().values().stream()\n          .map(v -> v.unwrap(org.projectnessie.model.Namespace.class))\n          .filter(Optional::isPresent)\n          .map(Optional::get)\n          .map(v -> Namespace.of(v.getElements().toArray(new String[0])))\n          .collect(Collectors.toList());\n    } catch (NessieNotFoundException e) {\n      if (namespace.isEmpty()) {\n        throw new NoSuchNamespaceException(\n            e,\n            \"Cannot list top-level namespaces: ref '%s' is no longer valid.\",\n            getRef().getName());\n      }\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 =","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L290-L326","documentation":"When listing top-level namespaces (empty namespace argument), a NessieNotFoundException from the entries/get-content call means the pinned reference itself no longer exists. The client converts it into NoSuchNamespaceException 'Cannot list top-level namespaces: ref ... is no longer valid.' The reference is stale or was deleted server-side.","triggerScenarios":"Calling Catalog.listNamespaces() (no args) against a Nessie catalog whose configured branch/tag was deleted after the catalog was instantiated.","commonSituations":"Long-lived Spark session holding a catalog bound to a branch that CI later deleted; typos in the ref name in catalog config; garbage-collected tags.","solutions":["Confirm the reference exists on the Nessie server and recreate it if missing.","Fix the 'ref' value in the catalog configuration (typo or removed branch).","Rebuild/reload the catalog so the reference is re-resolved to current HEAD."],"exampleFix":"// before\nconf.put(\"ref\", \"daily-etag\"); // tag GC'ed on server\nList<Namespace> ns = catalog.listNamespaces(); // throws\n// after\nconf.put(\"ref\", \"main\"); // stable branch","handlingStrategy":"validation","validationCode":"boolean refExists = api.getAllReferences().get().getReferences().stream()\n    .anyMatch(r -> r.getName().equals(configuredRef));\nif (!refExists) throw new IllegalStateException(\"Ref missing: \" + configuredRef);","typeGuard":null,"tryCatchPattern":"try {\n  return catalog.listNamespaces();\n} catch (NoSuchNamespaceException e) {\n  if (e.getMessage().contains(\"no longer valid\")) return rebuildCatalogAndList();\n  throw e;\n}","preventionTips":["Pin catalogs to stable branches, not ephemeral tags.","Validate ref existence at catalog startup.","Re-create the catalog object after any branch recreate."],"tags":["nessie","namespace","stale-reference"],"backgroundTag":"resource-not-found","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"}