{"record":{"id":"6133bfdae8e188c3","repo":"apache/iceberg","slug":"cannot-list-tables-for-namespace-namespace-does-n","errorCode":null,"errorMessage":"Cannot list tables for namespace. Namespace does not exist: %s","messagePattern":"Cannot list tables for namespace\\. Namespace does not exist: (.+?)","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java","lineNumber":154,"sourceCode":"    }\n\n    synchronized (this) {\n      if (null == tables.remove(tableIdentifier)) {\n        return false;\n      }\n    }\n\n    if (purge && lastMetadata != null) {\n      CatalogUtil.dropTableData(ops.io(), lastMetadata);\n    }\n\n    return true;\n  }\n\n  @Override\n  public List<TableIdentifier> listTables(Namespace namespace) {\n    if (!namespaceExists(namespace) && !namespace.isEmpty()) {\n      throw new NoSuchNamespaceException(\n          \"Cannot list tables for namespace. Namespace does not exist: %s\", namespace);\n    }\n\n    return tables.keySet().stream()\n        .filter(t -> t.namespace().equals(namespace))\n        .sorted(Comparator.comparing(TableIdentifier::toString))\n        .collect(Collectors.toList());\n  }\n\n  @Override\n  public void renameTable(TableIdentifier from, TableIdentifier to) {\n    if (from.equals(to)) {\n      return;\n    }\n\n    synchronized (this) {\n      if (!namespaceExists(to.namespace())) {\n        throw new NoSuchNamespaceException(","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/inmemory/InMemoryCatalog.java#L136-L172","documentation":"InMemoryCatalog.listTables throws NoSuchNamespaceException when the requested namespace does not exist and is not empty (root). The in-memory catalog keeps namespaces explicitly; listing tables requires a valid namespace.","triggerScenarios":"Calling catalog.listTables(Namespace.of(\"a\")) where namespace \"a\" was never created (or was dropped). Passing a multi-level namespace whose parent exists but leaf does not.","commonSituations":"Hardcoded namespace names that drift from what was created in tests; namespaces dropped by prior cleanup; case-sensitivity mismatches in namespace strings.","solutions":["Call namespaceExists(namespace) first and create it if missing","Correct the namespace identifier spelling/casing","List namespaces with listNamespaces() to see what exists","Catch NoSuchNamespaceException and return an empty list if acceptable"],"exampleFix":"// before\nList<TableIdentifier> tables = catalog.listTables(Namespace.of(\"reporting\"));\n// after\nNamespace ns = Namespace.of(\"reporting\");\nif (catalog.namespaceExists(ns)) {\n  List<TableIdentifier> tables = catalog.listTables(ns);\n}","handlingStrategy":"validation","validationCode":"Namespace ns = Namespace.of(\"reporting\");\nif (!catalog.namespaceExists(ns)) { catalog.createNamespace(ns); }","typeGuard":null,"tryCatchPattern":"try { return catalog.listTables(ns); } catch (NoSuchNamespaceException e) { return List.of(); }","preventionTips":["Create namespaces explicitly in setup before use","Compare namespace spellings with listNamespaces() output","Keep namespace definitions in one shared constant/helper","Account for case sensitivity in namespace names"],"tags":["inmemory-catalog","namespace","no-such-namespace"],"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"}