{"record":{"id":"f60b960a7b15126c","repo":"apache/pulsar","slug":"tenant-is-not-provided-f60b96","errorCode":null,"errorMessage":"Tenant is not provided","messagePattern":"Tenant is not provided","errorType":"validation","errorClass":"RestException","httpStatus":400,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java","lineNumber":92,"sourceCode":"        super(workerServiceSupplier, FunctionDetails.ComponentType.FUNCTION);\n    }\n\n    @Override\n    public void registerFunction(final String tenant,\n                                 final String namespace,\n                                 final String functionName,\n                                 final InputStream uploadedInputStream,\n                                 final FormDataContentDisposition fileDetail,\n                                 final String functionPkgUrl,\n                                 final FunctionConfig functionConfig,\n                                 final AuthenticationParameters authParams) {\n\n        if (!isWorkerServiceAvailable()) {\n            throwUnavailableException();\n        }\n\n        if (tenant == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Tenant is not provided\");\n        }\n        if (namespace == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Namespace is not provided\");\n        }\n        if (functionName == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Function name is not provided\");\n        }\n        if (functionConfig == null) {\n            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;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java#L74-L110","documentation":"FunctionsImpl.registerFunction validates the request before contacting the broker and rejects it with HTTP 400 if the tenant path/query parameter is null. The tenant is the first segment of the function's qualified name and is mandatory for every registration.","triggerScenarios":"Calling POST /admin/v3/functions/{tenant}/{namespace}/{functionName} or the Java/CLI registration API with the tenant field null or empty — typically a malformed URL path or a FunctionConfig built without setTenant().","commonSituations":"Building the REST URL by string concatenation and dropping a segment; deserializing a FunctionConfig JSON that lacks the tenant field; CLI scripts with an unset variable.","solutions":["Set tenant in the request path (and FunctionConfig.tenant) e.g. tenant 'public'","Check the client call: client.newFunction().tenant(...)... must include .tenant()","Print/inspect the FunctionConfig before submit to confirm tenant is populated"],"exampleFix":"// before\nFunctionConfig cfg = new FunctionConfig(); cfg.setNamespace(\"default\");\n// after\nFunctionConfig cfg = new FunctionConfig(); cfg.setTenant(\"public\"); cfg.setNamespace(\"default\");","handlingStrategy":"validation","validationCode":"if (cfg.getTenant() == null || cfg.getTenant().isEmpty()) throw new IllegalArgumentException(\"tenant required\");","typeGuard":"boolean hasTenant(FunctionConfig cfg) { return cfg != null && cfg.getTenant() != null && !cfg.getTenant().isEmpty(); }","tryCatchPattern":"try { admin.functions().createFunction(...); }\ncatch (PulsarAdminException e) {\n    if (e.getStatusCode() == 400 && String.valueOf(e.getMessage()).contains(\"Tenant is not provided\")) {\n        // set tenant and resubmit\n    }\n}","preventionTips":["Always set tenant/namespace/name on FunctionConfig before submit","Build REST URLs from a helper that asserts all path segments are non-empty","Validate the config with a shared pre-submit checker in scripts/CI"],"tags":["pulsar-functions","rest-api","validation"],"backgroundTag":"missing-required-parameter","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"}