{"record":{"id":"fb67e177be8e5318","repo":"apache/pulsar","slug":"namespace-is-not-provided-fb67e1","errorCode":null,"errorMessage":"Namespace is not provided","messagePattern":"Namespace 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":93,"sourceCode":"    @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;\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":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java#L75-L111","documentation":"registerSource validates that the namespace path parameter is present. A null namespace yields HTTP 400 'Namespace is not provided'. Same required-argument pattern as the tenant check, evaluated in order tenant → namespace → sourceName → sourceConfig.","triggerScenarios":"POST /admin/v3/sources/{tenant}/{namespace}/{sourceName} with a missing/empty namespace segment, or programmatic createSource/registerSource calls passing null namespace.","commonSituations":"Malformed REST URLs (only tenant given); scripts with unset NAMESPACE variables; SDK wrapper bugs defaulting namespace to null.","solutions":["Supply the namespace in the URL path: /admin/v3/sources/<tenant>/<namespace>/<name>.","Create the namespace first: pulsar-admin namespaces create <tenant>/<namespace>.","Fix scripts/SDK calls so the namespace parameter is populated (e.g. default to 'public/default' when appropriate)."],"exampleFix":"// before\nString ns = System.getenv(\"NAMESPACE\"); // unset -> null\nadmin.sources().createSource(tenant, ns, sourceName, fileName, config);\n// after\nString ns = Objects.requireNonNullElse(System.getenv(\"NAMESPACE\"), \"public/default\");","handlingStrategy":"validation","validationCode":"if (namespace == null || namespace.isBlank()) throw new IllegalArgumentException(\"namespace is required\");","typeGuard":"boolean isValidNamespace(String ns) { return ns != null && ns.matches(\"[A-Za-z0-9_\\\\-.=]+\"); }","tryCatchPattern":"try { admin.sources().createSource(tenant, ns, name, file, cfg); } catch (PulsarAdminException e) { if (e.getStatusCode() == 400) { /* fix parameters */ } throw e; }","preventionTips":["Default namespace in configs (e.g. public/default) instead of leaving null","Validate all path segments before calling the REST API","Check env/CI variables for emptiness before deploy steps","Create tenants/namespaces during bootstrap"],"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-14T05:17:10.506Z"}