{"record":{"id":"aa8b6f0aabc4e35b","repo":"apache/pulsar","slug":"namespace-is-not-provided-aa8b6f","errorCode":null,"errorMessage":"Namespace is not provided","messagePattern":"Namespace is not provided","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":94,"sourceCode":"    @Override\n    public void registerSink(final String tenant,\n                             final String namespace,\n                             final String sinkName,\n                             final InputStream uploadedInputStream,\n                             final FormDataContentDisposition fileDetail,\n                             final String sinkPkgUrl,\n                             final SinkConfig sinkConfig,\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 (sinkName == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Sink name is not provided\");\n        }\n        if (sinkConfig == null) {\n            throw new RestException(Response.Status.BAD_REQUEST, \"Sink config is not provided\");\n        }\n\n        throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, sinkName, \"register\", authParams);\n\n        try {\n            // Check tenant exists\n            worker().getBrokerAdmin().tenants().getTenantInfo(tenant);\n\n            String qualifiedNamespace = tenant + \"/\" + namespace;\n            List<String> namespaces = worker().getBrokerAdmin().namespaces().getNamespaces(tenant);\n            if (namespaces != null && !namespaces.contains(qualifiedNamespace)) {\n                String qualifiedNamespaceWithCluster = String.format(\"%s/%s/%s\", tenant,","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SinksImpl.java#L76-L112","documentation":"registerSink in SinksImpl throws a 400 Bad Request RestException when the namespace parameter is null. The namespace, together with the tenant, locates the destination namespace-politics for the sink; without it the component cannot be placed. The check runs immediately after the tenant check and before sink-name/sink-config validation.","triggerScenarios":"Calling the sink registration endpoint with namespace=null: missing namespace path segment in the URL, or a null namespace passed to SinksImpl.registerSink.","commonSituations":"Same as the missing-tenant case: templating helpers dropping empty segments, empty environment variables, or SDK defaults that leave namespace unset because the caller assumed a default namespace exists.","solutions":["Populate the namespace path segment: PUT /admin/v3/sinks/{tenant}/{namespace}/{sinkName}.","Verify the namespace actually exists (pulsar-admin namespaces list tenant/) - if it does not, create it first.","Guard the namespace value for null/blank in client code before invoking the API."],"exampleFix":"// before\nsinks.registerSink(tenant, null, sinkName, ...);\n// after\nif (namespace == null || namespace.isBlank()) {\n    throw new IllegalArgumentException(\"namespace is required\");\n}\nsinks.registerSink(tenant, namespace, sinkName, ...);","handlingStrategy":"validation","validationCode":"if (namespace == null || namespace.isBlank()) {\n    throw new IllegalArgumentException(\"namespace must be provided\");\n}","typeGuard":"boolean hasNamespace(String namespace) {\n    return namespace != null && !namespace.isBlank();\n}","tryCatchPattern":"try {\n    sinks.registerSink(tenant, ns, name, cfg, null, null, null, authParams);\n} catch (RestException e) {\n    if (e.getResponse().getStatus() == 400 && \"Namespace is not provided\".equals(e.getMessage())) {\n        // supply namespace and retry\n    } else { throw e; }\n}","preventionTips":["Assert namespace is set in the same validation pass as tenant and sink name","Do not assume a default namespace exists - always pass it explicitly","Validate the namespace exists on the target cluster before registering components"],"tags":["rest-api","bad-request","validation","pulsar-sinks"],"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"}