apache/iceberg · error · NoSuchNamespaceException

Cannot find namespace %s

Error message

Cannot find namespace %s

What it means

DynamoDbCatalog.loadNamespaceMetadata() performs a consistent GetItem for the namespace's primary key; if no item is returned it throws NoSuchNamespaceException with this message. It signals that the requested namespace does not exist in the DynamoDB-backed catalog.

Source

Thrown at aws/src/main/java/org/apache/iceberg/aws/dynamodb/DynamoDbCatalog.java:272

    } while (!lastEvaluatedKey.isEmpty());

    return namespaces;
  }

  @Override
  public Map<String, String> loadNamespaceMetadata(Namespace namespace)
      throws NoSuchNamespaceException {
    validateNamespace(namespace);
    GetItemResponse response =
        dynamo.getItem(
            GetItemRequest.builder()
                .tableName(awsProperties.dynamoDbTableName())
                .consistentRead(true)
                .key(namespacePrimaryKey(namespace))
                .build());

    if (!response.hasItem()) {
      throw new NoSuchNamespaceException("Cannot find namespace %s", namespace);
    }

    return response.item().entrySet().stream()
        .filter(e -> isProperty(e.getKey()))
        .collect(Collectors.toMap(e -> toPropertyKey(e.getKey()), e -> e.getValue().s()));
  }

  @Override
  public boolean dropNamespace(Namespace namespace) throws NamespaceNotEmptyException {
    validateNamespace(namespace);
    if (!listTables(namespace).isEmpty()) {
      throw new NamespaceNotEmptyException("Cannot delete non-empty namespace %s", namespace);
    }

    try {
      dynamo.deleteItem(
          DeleteItemRequest.builder()
              .tableName(awsProperties.dynamoDbTableName())

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Verify the namespace name spelling and case, then create it with catalog.createNamespace(namespace) if genuinely missing.
  2. Check the catalog configuration (s3.table.dynamo-db-table-name, region, credentials) to ensure you are reading the intended catalog table.
  3. If the namespace was dropped intentionally, update the calling code to handle NoSuchNamespaceException.

Example fix

// before
Map<String, String> props = catalog.loadNamespaceMetadata(Namespace.of("Analytcis"));

// after
Namespace ns = Namespace.of("analytics");
if (!catalog.namespaceExists(ns)) {
  catalog.createNamespace(ns);
}
Map<String, String> props = catalog.loadNamespaceMetadata(ns);
Defensive patterns

Strategy: validation

Validate before calling

Namespace ns = Namespace.of("analytics");
if (!catalog.namespaceExists(ns)) {
  throw new IllegalStateException("Namespace " + ns + " not found in " + catalogName);
}

Try / catch

try {
  props = catalog.loadNamespaceMetadata(ns);
} catch (NoSuchNamespaceException e) {
  props = Map.of(); // or create the namespace / fail fast with clear context
}

Prevention

When it happens

Trigger: Calling catalog.loadNamespaceMetadata(namespace), listTables flows that validate the namespace, or any catalog operation that resolves a namespace when the DynamoDB item for that key is absent (never created or already dropped).

Common situations: Misspelled or case-mismatched namespace name; querying after dropNamespace; pointing the catalog at the wrong DynamoDB table or region; an environment (dev vs prod) that never had the namespace created.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/2997ee03358c5647. Report an issue: GitHub.