{"record":{"id":"c6b4fcdd23794b7b","repo":"apache/pulsar","slug":"tenant-is-not-provided-c6b4fc","errorCode":null,"errorMessage":"Tenant is not provided","messagePattern":"Tenant is not provided","errorType":"http","errorClass":"RestException","httpStatus":400,"severity":"warning","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java","lineNumber":90,"sourceCode":"        super(workerServiceSupplier, FunctionDetails.ComponentType.SOURCE);\n    }\n\n    @Override\n    public void registerSource(final String tenant,\n                               final String namespace,\n                               final String sourceName,\n                               final InputStream uploadedInputStream,\n                               final FormDataContentDisposition fileDetail,\n                               final String sourcePkgUrl,\n                               final SourceConfig sourceConfig,\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 (sourceName == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Source name is not provided\");\n        }\n        if (sourceConfig == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Source config is not provided\");\n        }\n\n        throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, sourceName, \"register\", authParams);\n\n        try {\n            // Check tenant exists\n            worker().getBrokerAdmin().tenants().getTenantInfo(tenant);\n\n            String qualifiedNamespace = tenant + \"/\" + namespace;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java#L72-L108","documentation":"registerSource performs basic parameter validation before doing any work. If the tenant path parameter is null, it returns HTTP 400 'Tenant is not provided'. It is a plain required-argument check on the REST endpoint.","triggerScenarios":"POST /admin/v3/sources/{tenant}/{namespace}/{sourceName} with an empty/missing tenant path segment, or programmatic calls to Sinks/Sources REST API where the tenant variable was never set (null).","commonSituations":"Hand-built curl/REST calls with a malformed URL path; templated deployment scripts where a TENANT variable was empty; client SDK misuse passing null tenant.","solutions":["Include a valid tenant in the URL path: POST /admin/v3/sources/<tenant>/<namespace>/<name>.","Create the tenant first if it does not exist: pulsar-admin tenants create <tenant>.","Check deployment scripts so the tenant variable is non-empty before invoking the API."],"exampleFix":"// before\nadmin.sources().createSource(null, namespace, sourceName, fileName, config); // NPE -> 400\n// after\nif (tenant == null || tenant.isBlank()) throw new IllegalArgumentException(\"tenant required\");\nadmin.sources().createSource(tenant, namespace, sourceName, fileName, config);","handlingStrategy":"validation","validationCode":"if (tenant == null || tenant.isBlank()) throw new IllegalArgumentException(\"tenant is required\");","typeGuard":"boolean isValidTenant(String t) { return t != null && t.matches(\"[A-Za-z0-9_\\\\-.=]+\"); }","tryCatchPattern":"try { admin.sources().createSource(tenant, ns, name, file, cfg); } catch (PulsarAdminException e) { if (e.getStatusCode() == 400) { log.error(\"bad request: {}\", e.getMessage()); } throw e; }","preventionTips":["Validate path parameters before building REST URLs","Fail fast in scripts on empty env variables (set -u)","Use client SDKs instead of hand-built URLs","Create tenants as part of environment provisioning"],"tags":["validation","http-400","rest-api","missing-argument"],"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-14T00:17:10.932Z"}