{"record":{"id":"3638d40bd48a6a9a","repo":"apache/pulsar","slug":"tenant-does-not-exist-3638d4","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/SourcesImpl.java","lineNumber":131,"sourceCode":"                if (namespaces != null && !namespaces.contains(qualifiedNamespaceWithCluster)) {\n                    log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", sourceName)\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\", sourceName)\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\", sourceName)\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\", sourceName)\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, sourceName)) {\n            log.error().attr(\"componentType\", ComponentTypeUtils.toString(componentType)).attr(\"tenant\", tenant)\n\n                    .attr(\"namespace\", namespace).attr(\"componentName\", sourceName).log(\"/ / already exists\");\n            throw new RestException(Response.Status.BAD_REQUEST,\n                    String.format(\"%s %s already exists\", ComponentTypeUtils.toString(componentType), sourceName));\n        }\n\n        FunctionDetails functionDetails = null;","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java#L113-L149","documentation":"Thrown when the admin client's lookup of the tenant returns PulsarAdminException.NotFoundException during source registration; the worker maps this to HTTP 400 BAD_REQUEST with 'Tenant does not exist'. It means the tenant named in the request is absent from the cluster's metadata store.","triggerScenarios":"POSTing a source registration whose SourceConfig tenant field names a tenant that has not been created on the target cluster.","commonSituations":"Typo in the tenant name in source config YAML; deploying against a different cluster/environment than where the tenant was created; tenant deleted before redeployment; fresh cluster where bootstrap tenants were not provisioned.","solutions":["Verify existing tenants: pulsar-admin tenants list","Create the missing tenant: pulsar-admin tenants create <tenant> -r <admin-role>","Create the namespace too if needed: pulsar-admin namespaces create <tenant>/<namespace>","Correct the tenant field in your source configuration to an existing tenant"],"exampleFix":"// before\npulsar-admin sources create --tenant publc --namespace default ... // -> 400 Tenant does not exist\n// after\npulsar-admin tenants create publc -r administrator\n// or fix typo\npulsar-admin sources create --tenant public --namespace default ...","handlingStrategy":"validation","validationCode":"try (PulsarAdmin admin = PulsarAdminClient.builder().serviceHttpUrl(adminUrl).build()) {\n    if (!admin.tenants().getTenants().contains(tenant)) {\n        throw new IllegalStateException(\"Tenant \" + tenant + \" does not exist; create it first\");\n    }\n    admin.namespaces().getNamespaces(tenant); // also validates namespace\n}","typeGuard":null,"tryCatchPattern":"try {\n    sources.createSource(sourceConfig, pkgUrl, inputStream);\n} catch (PulsarAdminException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Tenant does not exist\")) {\n        admin.tenants().createTenant(tenant, new TenantInfoImpl(Collections.singleton(adminRole), Collections.singleton(\"standalone\")));\n        sources.createSource(sourceConfig, pkgUrl, inputStream);\n    } else { throw e; }\n}","preventionTips":["Run pulsar-admin tenants list before deployments to a new cluster","Create tenant+namespace in a pre-deploy provisioning step","Validate tenant name in source config against the cluster before upload","Keep per-environment configs so dev tenant names are not used in prod"],"tags":["tenant","not-found","rest-api","configuration"],"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-14T00:17:10.932Z"}