{"record":{"id":"92de3ca89297b967","repo":"apache/pulsar","slug":"tenant-does-not-exist-92de3c","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/SinksImpl.java","lineNumber":132,"sourceCode":"                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\");\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, sinkName)) {\n            log.error().attr(\"componentType\", ComponentTypeUtils.toString(componentType)).attr(\"tenant\", tenant)\n\n                    .attr(\"namespace\", namespace).attr(\"componentName\", sinkName).log(\"/ / already exists\");\n            throw new RestException(Response.Status.BAD_REQUEST,\n                    String.format(\"%s %s already exists\", ComponentTypeUtils.toString(componentType), sinkName));\n        }\n\n        FunctionDetails functionDetails;","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SinksImpl.java#L114-L150","documentation":"registerSink catches PulsarAdminException.NotFoundException from the PulsarAdmin tenant lookup and rethrows it as a 400 Bad Request RestException with the message \"Tenant does not exist\". It is thrown when the tenant referenced by the registration request has no corresponding tenant record in the broker's metadata store.","triggerScenarios":"registerSink with a tenant name that was never created, a misspelled tenant, or a tenant that was deleted while clients still reference it; the lookup happens via worker().getBrokerAdmin().tenants().getTenantInfo(tenant).","commonSituations":"Configuration drift between environments (tenant exists in staging but not production); typos in tenant names in deployment scripts; tenant purged by retention/cleanup jobs; running against the wrong broker URL.","solutions":["Create the tenant: pulsar-admin tenants create <tenant> --admin-roles <roles>.","Verify the tenant name with pulsar-admin tenants list and fix typos in your request.","Confirm you are pointing at the intended cluster/broker (check the worker's serviceUrl config).","If the tenant was deleted unintentionally, recreate it and reapply namespace/sink resources."],"exampleFix":"// before: tenant never created\nsinks.registerSink(\"my-tenant\", \"my-ns\", \"my-sink\", config, ...); // 400 Tenant does not exist\n// after\npulsar-admin tenants create my-tenant --admin-roles admin-role\nsinks.registerSink(\"my-tenant\", \"my-ns\", \"my-sink\", config, ...);","handlingStrategy":"validation","validationCode":"List<String> tenants = admin.tenants().getTenants();\nif (!tenants.contains(tenant)) {\n    throw new IllegalStateException(\"Tenant \" + tenant + \" does not exist; create it first\");\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 && \"Tenant does not exist\".equals(e.getMessage())) {\n        // create tenant via admin API, then retry registration\n    } else { throw e; }\n}","preventionTips":["Provision tenants declaratively before any component deployment","Centralize tenant names in config to avoid typos across environments","Verify broker/serviceUrl per environment so you never register against the wrong cluster"],"tags":["rest-api","bad-request","tenant","pulsar-sinks"],"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"}