apache/pulsar · error · RestException
Namespace does not exist
Error message
Namespace does not exist
What it means
registerSink validates that the requested namespace exists and belongs to the Pulsar Functions cluster. It queries the tenant's namespaces via PulsarAdmin and, if the list does not contain tenant/cluster/namespace, throws a 400 Bad Request RestException. This catches registrations into namespaces that either do not exist or are not hosted on the functions cluster.
Source
Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SinksImpl.java:118
throw new RestException(Response.Status.BAD_REQUEST, "Sink config is not provided");
}
throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, sinkName, "register", authParams);
try {
// Check tenant exists
worker().getBrokerAdmin().tenants().getTenantInfo(tenant);
String qualifiedNamespace = tenant + "/" + namespace;
List<String> namespaces = worker().getBrokerAdmin().namespaces().getNamespaces(tenant);
if (namespaces != null && !namespaces.contains(qualifiedNamespace)) {
String qualifiedNamespaceWithCluster = String.format("%s/%s/%s", tenant,
worker().getWorkerConfig().getPulsarFunctionsCluster(), namespace);
if (namespaces != null && !namespaces.contains(qualifiedNamespaceWithCluster)) {
log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", sinkName)
.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", sinkName)
.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", sinkName)
.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", sinkName)
.exception(e).log("/ / Issues getting tenant data");View on GitHub (pinned to 820761864e)
Solutions
- Create the namespace first: pulsar-admin namespaces create tenant/namespace.
- Confirm the namespace's cluster matches the functions worker's configured cluster (workerConfig.getPulsarFunctionsCluster()); set namespace clusters accordingly with set-clusters.
- Fix typos in the namespace name; list namespaces with pulsar-admin namespaces list tenant to verify.
- In multi-cluster deployments, ensure the worker's PULSAR_FUNCTIONS_CLUSTER config points at the cluster hosting the namespace.
Example fix
// before: namespace not created on the functions cluster pulsar-admin sinks create --tenant t --namespace wrong-ns ... // after pulsar-admin namespaces create t/correct-ns pulsar-admin namespaces set-clusters t/correct-ns --clusters my-functions-cluster pulsar-admin sinks create --tenant t --namespace correct-ns ...
Defensive patterns
Strategy: validation
Validate before calling
List<String> namespaces = admin.namespaces().getNamespaces(tenant);
String fqns = tenant + "/" + cluster + "/" + namespace;
if (namespaces == null || !namespaces.contains(fqns)) {
throw new IllegalStateException("Namespace " + namespace + " does not exist on cluster " + cluster);
} Try / catch
try {
sinks.registerSink(tenant, ns, name, cfg, null, null, null, authParams);
} catch (RestException e) {
if (e.getResponse().getStatus() == 400 && "Namespace does not exist".equals(e.getMessage())) {
// create the namespace on the functions cluster, then retry
} else { throw e; }
} Prevention
- Provision tenant + namespace (with correct cluster list) before deploying sinks
- In multi-cluster setups, keep workerConfig.getPulsarFunctionsCluster() in sync with namespace clusters
- Lint deployment manifests for tenant/namespace typos
When it happens
Trigger: registerSink where the tenant exists but the requested namespace does not, or the namespace exists on a different cluster than workerConfig.getPulsarFunctionsCluster(), so the fully-qualified name tenant/cluster/namespace is absent from the tenant's namespace list.
Common situations: Typo in the namespace name; creating the namespace after the tenant but on another cluster; georeplication setups where the functions cluster differs from the namespace's cluster; stale tenant/namespace lists in tests.
Related errors
- Tenant is not provided
- Namespace is not provided
- Sink name is not provided
- Sink config is not provided
- Tenant does not exist
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/a0bac2446666ccf0.
Report an issue: GitHub.