{"record":{"id":"c254458d46eecdd2","repo":"apache/iceberg","slug":"fail-to-find-glue-database-for-namespace-s-error","errorCode":null,"errorMessage":"fail to find Glue database for namespace %s, error message: %s","messagePattern":"fail to find Glue database for namespace (.+?), error message: (.+?)","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":null,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java","lineNumber":549,"sourceCode":"      Map<String, String> result = Maps.newHashMap(database.parameters());\n\n      if (database.locationUri() != null) {\n        result.put(\n            IcebergToGlueConverter.GLUE_DB_LOCATION_KEY,\n            LocationUtil.stripTrailingSlash(database.locationUri()));\n      }\n\n      if (database.description() != null) {\n        result.put(IcebergToGlueConverter.GLUE_DESCRIPTION_KEY, database.description());\n      }\n\n      LOG.debug(\"Loaded metadata for namespace {} found {}\", namespace, result);\n      return result;\n    } catch (InvalidInputException e) {\n      throw new NoSuchNamespaceException(\n          \"invalid input for namespace %s, error message: %s\", namespace, e.getMessage());\n    } catch (EntityNotFoundException e) {\n      throw new NoSuchNamespaceException(\n          \"fail to find Glue database for namespace %s, error message: %s\",\n          databaseName, e.getMessage());\n    }\n  }\n\n  @Override\n  public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {\n    namespaceExists(namespace);\n\n    GetTablesResponse response =\n        glue.getTables(\n            GetTablesRequest.builder()\n                .catalogId(awsProperties.glueCatalogId())\n                .databaseName(\n                    IcebergToGlueConverter.toDatabaseName(\n                        namespace, awsProperties.glueCatalogSkipNameValidation()))\n                .build());\n","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java#L531-L567","documentation":"GlueCatalog.loadNamespaceMetadata catches EntityNotFoundException from Glue's GetDatabase and rethrows it as NoSuchNamespaceException. It means no Glue database exists for the given namespace in the configured catalog ID, so Iceberg cannot load its metadata.","triggerScenarios":"Calling loadNamespaceMetadata(Namespace.of(\"db\")) where `db` was never created, was dropped, exists in another account/region than awsProperties.glueCatalogId, or the caller lacks Glue IAM permissions so the database appears absent.","commonSituations":"Environment mismatch (dev vs prod Glue catalogs); typos in namespace names; another pipeline dropped the database; assuming the catalog auto-creates namespaces when it does not.","solutions":["Check `catalog.namespaceExists(ns)` first, or create the namespace with createNamespace if missing.","Fix the namespace spelling and confirm it matches the Glue database name exactly.","Verify glueCatalogId / region configuration matches where the database actually exists.","Confirm IAM permissions allow glue:GetDatabase — denied access can manifest as not-found."],"exampleFix":"// before\nMap<String, String> meta = catalog.loadNamespaceMetadata(Namespace.of(\"sales\"));\n\n// after\nNamespace ns = Namespace.of(\"sales\");\nif (!catalog.namespaceExists(ns)) {\n  catalog.createNamespace(ns);\n}\nMap<String, String> meta = catalog.loadNamespaceMetadata(ns);","handlingStrategy":"try-catch","validationCode":"Namespace ns = Namespace.of(\"sales\");\nif (!catalog.namespaceExists(ns)) {\n  catalog.createNamespace(ns);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return catalog.loadNamespaceMetadata(ns);\n} catch (NoSuchNamespaceException e) {\n  LOG.error(\"Glue database for {} not found; check name, region, catalogId and IAM\", ns);\n  throw e;\n}","preventionTips":["Check namespaceExists before loading metadata","Pin glueCatalogId/region in config so dev/prod cannot be confused","Grant glue:GetDatabase to the runtime role"],"tags":["aws","glue","namespace","not-found"],"backgroundTag":"entity-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"}