{"record":{"id":"a0bac2446666ccf0","repo":"apache/pulsar","slug":"namespace-does-not-exist-a0bac2","errorCode":null,"errorMessage":"Namespace does not exist","messagePattern":"Namespace does not exist","errorType":"http","errorClass":"RestException","httpStatus":400,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SinksImpl.java","lineNumber":118,"sourceCode":"            throw new RestException(Response.Status.BAD_REQUEST, \"Sink config is not provided\");\n        }\n\n        throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, sinkName, \"register\", authParams);\n\n        try {\n            // Check tenant exists\n            worker().getBrokerAdmin().tenants().getTenantInfo(tenant);\n\n            String qualifiedNamespace = tenant + \"/\" + namespace;\n            List<String> namespaces = worker().getBrokerAdmin().namespaces().getNamespaces(tenant);\n            if (namespaces != null && !namespaces.contains(qualifiedNamespace)) {\n                String qualifiedNamespaceWithCluster = String.format(\"%s/%s/%s\", tenant,\n                        worker().getWorkerConfig().getPulsarFunctionsCluster(), namespace);\n                if (namespaces != null && !namespaces.contains(qualifiedNamespaceWithCluster)) {\n                    log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", sinkName)\n\n                            .attr(\"namespace3\", namespace).log(\"/ / Namespace does not exist\");\n                    throw new RestException(Response.Status.BAD_REQUEST, \"Namespace does not exist\");\n                }\n            }\n        } catch (PulsarAdminException.NotAuthorizedException e) {\n            log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", sinkName)\n\n                    .attr(\"componentType\", ComponentTypeUtils.toString(componentType))\n\n                    .log(\"/ / Client is not authorized to operate on tenant\");\n            throw new RestException(Response.Status.UNAUTHORIZED, \"Client is not authorized to perform operation\");\n        } catch (PulsarAdminException.NotFoundException e) {\n            log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", sinkName)\n\n                    .attr(\"tenant3\", tenant).log(\"/ / Tenant does not exist\");\n            throw new RestException(Response.Status.BAD_REQUEST, \"Tenant does not exist\");\n        } catch (PulsarAdminException e) {\n            log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", sinkName)\n\n                    .exception(e).log(\"/ / Issues getting tenant data\");","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SinksImpl.java#L100-L136","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: namespace not created on the functions cluster\npulsar-admin sinks create --tenant t --namespace wrong-ns ...\n// after\npulsar-admin namespaces create t/correct-ns\npulsar-admin namespaces set-clusters t/correct-ns --clusters my-functions-cluster\npulsar-admin sinks create --tenant t --namespace correct-ns ...","handlingStrategy":"validation","validationCode":"List<String> namespaces = admin.namespaces().getNamespaces(tenant);\nString fqns = tenant + \"/\" + cluster + \"/\" + namespace;\nif (namespaces == null || !namespaces.contains(fqns)) {\n    throw new IllegalStateException(\"Namespace \" + namespace + \" does not exist on cluster \" + cluster);\n}","typeGuard":null,"tryCatchPattern":"try {\n    sinks.registerSink(tenant, ns, name, cfg, null, null, null, authParams);\n} catch (RestException e) {\n    if (e.getResponse().getStatus() == 400 && \"Namespace does not exist\".equals(e.getMessage())) {\n        // create the namespace on the functions cluster, then retry\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["rest-api","bad-request","namespace","pulsar-sinks"],"backgroundTag":"namespace-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"}