{"record":{"id":"c6212823649a6959","repo":"apache/iceberg","slug":"cannot-find-default-warehouse-location-namespace","errorCode":null,"errorMessage":"Cannot find default warehouse location: namespace %s does not exist","messagePattern":"Cannot find default warehouse location: namespace (.+?) does not exist","errorType":"exception","errorClass":"NoSuchNamespaceException","httpStatus":404,"severity":"error","filePath":"aws/src/main/java/org/apache/iceberg/aws/dynamodb/DynamoDbCatalog.java","lineNumber":186,"sourceCode":"  @Override\n  protected TableOperations newTableOps(TableIdentifier tableIdentifier) {\n    validateTableIdentifier(tableIdentifier);\n    return new DynamoDbTableOperations(dynamo, awsProperties, catalogName, fileIO, tableIdentifier);\n  }\n\n  @Override\n  protected String defaultWarehouseLocation(TableIdentifier tableIdentifier) {\n    validateTableIdentifier(tableIdentifier);\n    GetItemResponse response =\n        dynamo.getItem(\n            GetItemRequest.builder()\n                .tableName(awsProperties.dynamoDbTableName())\n                .consistentRead(true)\n                .key(namespacePrimaryKey(tableIdentifier.namespace()))\n                .build());\n\n    if (!response.hasItem()) {\n      throw new NoSuchNamespaceException(\n          \"Cannot find default warehouse location: namespace %s does not exist\",\n          tableIdentifier.namespace());\n    }\n\n    String defaultLocationCol = toPropertyCol(PROPERTY_DEFAULT_LOCATION);\n    String tableLocation = LocationUtil.tableLocation(tableIdentifier, uniqueTableLocation);\n    if (response.item().containsKey(defaultLocationCol)) {\n      return String.format(\"%s/%s\", response.item().get(defaultLocationCol).s(), tableLocation);\n    } else {\n      return String.format(\n          \"%s/%s.db/%s\", warehousePath, tableIdentifier.namespace(), tableLocation);\n    }\n  }\n\n  @Override\n  public void createNamespace(Namespace namespace, Map<String, String> metadata) {\n    validateNamespace(namespace);\n    Map<String, AttributeValue> values = namespacePrimaryKey(namespace);","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/dynamodb/DynamoDbCatalog.java#L168-L204","documentation":"DynamoDbCatalog.defaultWarehouseLocation() computes the default table location for a new table by looking up the parent namespace's item in DynamoDB and reading its default-location property. If the namespace item does not exist, a NoSuchNamespaceException with this message is thrown, since a warehouse location cannot be derived without it.","triggerScenarios":"Calling catalog.buildTable(identifier, schema).create() (which invokes location -> defaultWarehouseLocation) when the table's namespace row is absent from the DynamoDB catalog table — e.g. the namespace was never created or was dropped beforehand.","commonSituations":"Creating a table in a namespace that was never explicitly created via createNamespace; a race where another job dropped the namespace; connecting to the wrong DynamoDB table (s3.table.dynamo-db-table-name) so the namespace lookup finds nothing; region mismatch so reads go to an empty table.","solutions":["Create the namespace first: catalog.createNamespace(namespace) or pass an explicit `location` property to the table builder so no warehouse lookup is needed.","Verify the catalog is pointing at the intended DynamoDB table and AWS region (s3.table.dynamo-db-table-name, region settings).","Recreate or restore the missing namespace item in the DynamoDB catalog table."],"exampleFix":"// before\ncatalog.buildTable(TableIdentifier.of(\"analytics\", \"events\"), schema).create();\n\n// after\nif (!catalog.namespaceExists(Namespace.of(\"analytics\"))) {\n  catalog.createNamespace(Namespace.of(\"analytics\"));\n}\ncatalog.buildTable(TableIdentifier.of(\"analytics\", \"events\"), schema).create();","handlingStrategy":"validation","validationCode":"DynamoDbCatalog catalog = ...;\nNamespace ns = tableIdentifier.namespace();\nif (!catalog.namespaceExists(ns)) {\n  catalog.createNamespace(ns);\n}","typeGuard":null,"tryCatchPattern":"try {\n  table = catalog.buildTable(id, schema).create();\n} catch (NoSuchNamespaceException e) {\n  catalog.createNamespace(id.namespace());\n  table = catalog.buildTable(id, schema).create();\n}","preventionTips":["Provision namespaces as part of environment setup before creating tables","Pass an explicit `location` in table properties to bypass warehouse-location lookups","Log the namespace and DynamoDB table name on failure to catch wrong-environment mistakes"],"tags":["aws","dynamodb","catalog","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"}