apache/pulsar · error · RestException

Tenant does not exist

Error message

Tenant does not exist

What it means

If the worker's PulsarAdmin call to fetch tenant data returns PulsarAdminException.NotFoundException, registerFunction converts it into HTTP 400 'Tenant does not exist'. Functions cannot be registered under a tenant that is not configured in the broker's metadata store.

Source

Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java:133

                if (!namespaces.contains(qualifiedNamespaceWithCluster)) {
                    log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", functionName)

                            .attr("namespace3", namespace).log("/ / Namespace does not exist");
                    throw new RestException(Response.Status.BAD_REQUEST, "Namespace does not exist");
                }
            }
        } catch (PulsarAdminException.NotAuthorizedException e) {
            log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", functionName)

                    .attr("componentType", ComponentTypeUtils.toString(componentType))

                    .log("/ / Client is not authorized to operate on tenant");
            throw new RestException(Response.Status.UNAUTHORIZED, "Client is not authorized to perform operation");
        } catch (PulsarAdminException.NotFoundException e) {
            log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", functionName)

                    .attr("tenant3", tenant).log("/ / Tenant does not exist");
            throw new RestException(Response.Status.BAD_REQUEST, "Tenant does not exist");
        } catch (PulsarAdminException e) {
            log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", functionName)

                    .exception(e).log("/ / Issues getting tenant data");
            throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
        }

        FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();

        if (functionMetaDataManager.containsFunction(tenant, namespace, functionName)) {
            log.error().attr("componentType", ComponentTypeUtils.toString(componentType)).attr("tenant", tenant)

                    .attr("namespace", namespace).attr("componentName", functionName).log("/ / already exists");
            throw new RestException(Response.Status.BAD_REQUEST, String.format("%s %s already exists",
                    ComponentTypeUtils.toString(componentType), functionName));
        }

        FunctionDetails functionDetails;

View on GitHub (pinned to 820761864e)

Solutions

  1. Create the tenant: 'pulsar-admin tenants create <tenant> --admin-roles <role>'
  2. List tenants ('pulsar-admin tenants list') to confirm the exact name/spelling
  3. Correct the tenant field in the FunctionConfig/request path

Example fix

// before
config.setTenant("acme"); // tenant not present on this cluster
// after
pulsar-admin tenants create acme --admin-roles admin
cfg.setTenant("acme");
Defensive patterns

Strategy: validation

Validate before calling

boolean tenantExists = admin.tenants().getTenants().contains(tenant);
if (!tenantExists) admin.tenants().createTenant(tenant, adminRoles);

Type guard

boolean tenantExists(String tenant, java.util.List<String> tenants) { return tenants != null && tenants.contains(tenant); }

Try / catch

try { admin.functions().createFunction(...); }
catch (PulsarAdminException e) {
    if (e.getStatusCode() == 400 && String.valueOf(e.getMessage()).contains("Tenant does not exist")) {
        admin.tenants().createTenant(tenant, adminRoles); // then retry
    }
}

Prevention

When it happens

Trigger: Registering a function with tenant X when tenant X was never created (or was deleted), so the tenant lookup 404s.

Common situations: Typo in tenant name; deploying to a fresh cluster where only 'public' exists; tenant deleted by an operator; multi-cluster setup where the tenant exists on a different cluster/instance.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/94aca55016f17dec. Report an issue: GitHub.