{"record":{"id":"8ea25e60f3e106c8","repo":"apache/iceberg","slug":"cannot-list-child-namespaces-from-s-ref-s-i","errorCode":null,"errorMessage":"Cannot list child namespaces from '%s': ref '%s' is no longer valid.","messagePattern":"Cannot list child namespaces from '(.+?)': 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":313,"sourceCode":"      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 =\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);","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/nessie/src/main/java/org/apache/iceberg/nessie/NessieIcebergClient.java#L295-L331","documentation":"Same stale-reference condition as the top-level variant, but raised when listing CHILD namespaces: the initial existence check or the filtered entries query for namespace X hit NessieNotFoundException because the pinned ref no longer exists. Message names the parent namespace and the dead ref.","triggerScenarios":"Calling Catalog.listNamespaces(Namespace.of(\"parent\")) when the catalog's configured reference was deleted server-side.","commonSituations":"Branch deleted by another process while a job iterates namespaces; misconfigured ref name; tag expired.","solutions":["Verify/recreate the reference on the Nessie server.","Correct the catalog 'ref' configuration.","Re-instantiate the catalog to re-resolve the reference hash."],"exampleFix":"// before\ncatalog.listNamespaces(Namespace.of(\"staging\")); // ref deleted -> throws\n// after\nif (Boolean.TRUE.equals(api.getAllReferences().get().getReferences().stream()\n        .anyMatch(r -> r.getName().equals(refName)))) {\n  catalog.listNamespaces(Namespace.of(\"staging\"));\n}","handlingStrategy":"validation","validationCode":"if (!refExists(api, configuredRef)) return List.of();\nreturn catalog.listNamespaces(parentNamespace);","typeGuard":null,"tryCatchPattern":"try {\n  return catalog.listNamespaces(parent);\n} catch (NoSuchNamespaceException e) {\n  if (e.getMessage().contains(\"no longer valid\")) {\n    throw new RefGoneException(e); // force caller to re-resolve ref\n  }\n  throw e;\n}","preventionTips":["Check ref existence before namespace operations in batch jobs.","Avoid deleting branches during scheduled namespace scans.","Use default-branch fallback logic for resilience."],"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-14T11:17:12.474Z"}