{"record":{"id":"3a483c500176d8e2","repo":"apache/pulsar","slug":"namespace-does-not-exist-3a483c","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/FunctionsImpl.java","lineNumber":119,"sourceCode":"            throw new RestException(Response.Status.BAD_REQUEST, \"Function config is not provided\");\n        }\n\n        throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, functionName, \"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.contains(qualifiedNamespaceWithCluster)) {\n                    log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", functionName)\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\", functionName)\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\", functionName)\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\", functionName)\n\n                    .exception(e).log(\"/ / Issues getting tenant data\");","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java#L101-L137","documentation":"After the mandatory-field checks, registerFunction queries the broker for the tenant's namespaces; when the functions cluster is set and the requested namespace (or tenant/namespace/cluster triple) is not among them, it fails with HTTP 400 'Namespace does not exist'. The function must be registered into an existing namespace scoped to the Pulsar Functions cluster.","triggerScenarios":"Registering into tenant/namespace that was never created, or a namespace that exists on a different cluster than workerConfig.getPulsarFunctionsCluster(); also raised when the listing call itself finds nothing for that tenant.","commonSituations":"Typo in namespace name; namespace created on cluster 'local' but functions cluster configured as 'prod'; using a fresh install where 'public/default' was never provisioned; global vs per-cluster namespace replication mismatch.","solutions":["Create the namespace: 'pulsar-admin namespaces create <tenant>/<namespace>'","Confirm the namespace is listed under the functions cluster: 'pulsar-admin namespaces list <tenant>' and compare with getPulsarFunctionsCluster()","Fix the tenant/namespace spelling in the registration request","Align workerConfig's pulsarFunctionsCluster with the cluster the namespace belongs to"],"exampleFix":"// before\n// namespace 'analytics' does not exist on functions cluster\nadmin.functions().createFunction(tenant, \"analytics\", ...);\n// after\nadmin.namespaces().createNamespace(tenant + \"/analytics\");\nadmin.functions().createFunction(tenant, \"analytics\", ...);","handlingStrategy":"validation","validationCode":"try {\n    boolean exists = admin.namespaces().getNamespaces(tenant).stream()\n        .anyMatch(n -> n.endsWith(\"/\" + namespace));\n    if (!exists) throw new IllegalStateException(\"namespace \" + tenant + \"/\" + namespace + \" missing\");\n} catch (PulsarAdminException e) { throw new IllegalStateException(\"cannot verify namespace\", e); }","typeGuard":"boolean namespaceExists(String tenant, String ns, java.util.List<String> all) {\n    return all != null && all.stream().anyMatch(n -> n.equals(tenant + \"/\" + ns));\n}","tryCatchPattern":"try { admin.functions().createFunction(...); }\ncatch (PulsarAdminException e) {\n    if (e.getStatusCode() == 400 && String.valueOf(e.getMessage()).contains(\"Namespace does not exist\")) {\n        admin.namespaces().createNamespace(tenant + \"/\" + namespace); // then retry\n    }\n}","preventionTips":["Provision tenant/namespace as a prerequisite step in deployment","Cross-check namespace cluster assignment with the worker's pulsarFunctionsCluster","Validate names with pulsar-admin before automated registrations"],"tags":["pulsar-functions","namespace","rest-api"],"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-14T05:17:10.506Z"}