{"record":{"id":"94aca55016f17dec","repo":"apache/pulsar","slug":"tenant-does-not-exist-94aca5","errorCode":null,"errorMessage":"Tenant does not exist","messagePattern":"Tenant 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":133,"sourceCode":"                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\");\n            throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());\n        }\n\n        FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();\n\n        if (functionMetaDataManager.containsFunction(tenant, namespace, functionName)) {\n            log.error().attr(\"componentType\", ComponentTypeUtils.toString(componentType)).attr(\"tenant\", tenant)\n\n                    .attr(\"namespace\", namespace).attr(\"componentName\", functionName).log(\"/ / already exists\");\n            throw new RestException(Response.Status.BAD_REQUEST, String.format(\"%s %s already exists\",\n                    ComponentTypeUtils.toString(componentType), functionName));\n        }\n\n        FunctionDetails functionDetails;","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java#L115-L151","documentation":"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.","triggerScenarios":"Registering a function with tenant X when tenant X was never created (or was deleted), so the tenant lookup 404s.","commonSituations":"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.","solutions":["Create the tenant: 'pulsar-admin tenants create <tenant> --admin-roles <role>'","List tenants ('pulsar-admin tenants list') to confirm the exact name/spelling","Correct the tenant field in the FunctionConfig/request path"],"exampleFix":"// before\nconfig.setTenant(\"acme\"); // tenant not present on this cluster\n// after\npulsar-admin tenants create acme --admin-roles admin\ncfg.setTenant(\"acme\");","handlingStrategy":"validation","validationCode":"boolean tenantExists = admin.tenants().getTenants().contains(tenant);\nif (!tenantExists) admin.tenants().createTenant(tenant, adminRoles);","typeGuard":"boolean tenantExists(String tenant, java.util.List<String> tenants) { return tenants != null && tenants.contains(tenant); }","tryCatchPattern":"try { admin.functions().createFunction(...); }\ncatch (PulsarAdminException e) {\n    if (e.getStatusCode() == 400 && String.valueOf(e.getMessage()).contains(\"Tenant does not exist\")) {\n        admin.tenants().createTenant(tenant, adminRoles); // then retry\n    }\n}","preventionTips":["Create tenants in environment bootstrap before function deployments","Validate tenant spelling against 'pulsar-admin tenants list'","Use a shared config source for tenant names to avoid typos"],"tags":["pulsar-functions","tenant","rest-api"],"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-14T05:17:10.506Z"}