{"record":{"id":"ff26eb7b8bbe98d4","repo":"apache/pulsar","slug":"tenant-not-found","errorCode":null,"errorMessage":"Tenant not found","messagePattern":"Tenant not found","errorType":"http","errorClass":"RestException","httpStatus":404,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java","lineNumber":148,"sourceCode":"\n    protected CompletableFuture<List<String>> internalGetTenantNamespaces(String tenant) {\n        if (tenant == null) {\n            return FutureUtil.failedFuture(new RestException(Status.BAD_REQUEST, \"Tenant should not be null\"));\n        }\n        try {\n            NamedEntity.checkName(tenant);\n        } catch (IllegalArgumentException e) {\n            log.warn()\n                    .attr(\"tenant\", tenant)\n                    .exception(e)\n                    .log(\"Tenant name is invalid\");\n            return FutureUtil.failedFuture(new RestException(Status.PRECONDITION_FAILED, \"Tenant name is not valid\"));\n        }\n        return validateTenantOperationAsync(tenant, TenantOperation.LIST_NAMESPACES)\n                .thenCompose(__ -> tenantResources().tenantExistsAsync(tenant))\n                .thenCompose(existed -> {\n                    if (!existed) {\n                        throw new RestException(Status.NOT_FOUND, \"Tenant not found\");\n                    }\n                    return tenantResources().getListOfNamespacesAsync(tenant);\n                });\n    }\n\n    protected CompletableFuture<Void> internalCreateNamespace(Policies policies) {\n        return validateTenantOperationAsync(namespaceName.getTenant(), TenantOperation.CREATE_NAMESPACE)\n                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())\n                .thenCompose(__ -> validatePoliciesAsync(namespaceName, policies))\n                .thenCompose(__ -> {\n                    int maxNamespacesPerTenant = pulsar().getConfiguration().getMaxNamespacesPerTenant();\n                    // no distributed locks are added here.In a concurrent scenario, the threshold will be exceeded.\n                    if (maxNamespacesPerTenant > 0) {\n                        return tenantResources().getListOfNamespacesAsync(namespaceName.getTenant())\n                                .thenAccept(namespaces -> {\n                                    if (namespaces != null && namespaces.size() > maxNamespacesPerTenant) {\n                                        throw new RestException(Status.PRECONDITION_FAILED,\n                                                \"Exceed the maximum number of namespace in tenant :\"","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L130-L166","documentation":"A 404 NOT_FOUND thrown by the namespace listing flow when the tenant referenced in the request does not exist. After validating the tenant operation (LIST_NAMESPACES) and checking tenant existence via tenantResources().tenantExistsAsync, a missing tenant produces this error.","triggerScenarios":"GET /admin/v3/namespaces/{tenant} where the tenant was deleted, never created, or the name is mistyped (case-sensitivity/typo) on a cluster where it doesn't exist.","commonSituations":"Stale configuration in clients pointing at a removed tenant; multi-cluster setups where the tenant exists only on another cluster; typos like 'my-tennat'; tenant deletion racing with namespace list calls.","solutions":["Confirm the tenant exists: GET /admin/v3/tenants (or pulsar-admin tenants list) and use an exact existing tenant name.","Create the tenant if missing: pulsar-admin tenants create <tenant> with admin roles and allowed clusters.","Check which cluster the request targets — the tenant may exist on a different cluster."],"exampleFix":"// before\nadmin.namespaces().getNamespaces(\"my-tennat\"); // 404\n// after\nif (admin.tenants().getTenants().contains(\"mytenant\")) {\n    admin.namespaces().getNamespaces(\"mytenant\");\n}","handlingStrategy":"try-catch","validationCode":"if (!admin.tenants().getTenants().contains(tenant)) {\n  throw new IllegalStateException(\"tenant \" + tenant + \" does not exist on this cluster\");\n}","typeGuard":null,"tryCatchPattern":"try { admin.namespaces().getNamespaces(tenant); }\ncatch (PulsarAdminException e) {\n  if (e.getStatusCode() == 404 && e.getMessage().contains(\"Tenant not found\")) {\n    admin.tenants().createTenant(tenant, ...);\n  } else throw e;\n}","preventionTips":["Validate tenant names against the tenants list before namespace operations","Watch for typos/case mismatches in tenant names","Re-check config after tenant deletions","Point clients at the correct cluster where the tenant exists"],"tags":["not-found","tenant","rest-api","admin"],"backgroundTag":"tenant-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}