apache/pulsar · warning · RestException

Namespace is not provided

Error message

Namespace is not provided

What it means

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.

Source

Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java:93

    @Override
    public void registerSource(final String tenant,
                               final String namespace,
                               final String sourceName,
                               final InputStream uploadedInputStream,
                               final FormDataContentDisposition fileDetail,
                               final String sourcePkgUrl,
                               final SourceConfig sourceConfig,
                               final AuthenticationParameters authParams) {

        if (!isWorkerServiceAvailable()) {
            throwUnavailableException();
        }

        if (tenant == null) {
            throw new RestException(Response.Status.BAD_REQUEST, "Tenant is not provided");
        }
        if (namespace == null) {
            throw new RestException(Response.Status.BAD_REQUEST, "Namespace is not provided");
        }
        if (sourceName == null) {
            throw new RestException(Response.Status.BAD_REQUEST, "Source name is not provided");
        }
        if (sourceConfig == null) {
            throw new RestException(Response.Status.BAD_REQUEST, "Source config is not provided");
        }

        throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, sourceName, "register", authParams);

        try {
            // Check tenant exists
            worker().getBrokerAdmin().tenants().getTenantInfo(tenant);

            String qualifiedNamespace = tenant + "/" + namespace;
            List<String> namespaces = worker().getBrokerAdmin().namespaces().getNamespaces(tenant);
            if (namespaces != null && !namespaces.contains(qualifiedNamespace)) {
                String qualifiedNamespaceWithCluster = String.format("%s/%s/%s", tenant,

View on GitHub (pinned to 820761864e)

Solutions

  1. Supply the namespace in the URL path: /admin/v3/sources/<tenant>/<namespace>/<name>.
  2. Create the namespace first: pulsar-admin namespaces create <tenant>/<namespace>.
  3. Fix scripts/SDK calls so the namespace parameter is populated (e.g. default to 'public/default' when appropriate).

Example fix

// before
String ns = System.getenv("NAMESPACE"); // unset -> null
admin.sources().createSource(tenant, ns, sourceName, fileName, config);
// after
String ns = Objects.requireNonNullElse(System.getenv("NAMESPACE"), "public/default");
Defensive patterns

Strategy: validation

Validate before calling

if (namespace == null || namespace.isBlank()) throw new IllegalArgumentException("namespace is required");

Type guard

boolean isValidNamespace(String ns) { return ns != null && ns.matches("[A-Za-z0-9_\\-.=]+"); }

Try / catch

try { admin.sources().createSource(tenant, ns, name, file, cfg); } catch (PulsarAdminException e) { if (e.getStatusCode() == 400) { /* fix parameters */ } throw e; }

Prevention

When it happens

Trigger: POST /admin/v3/sources/{tenant}/{namespace}/{sourceName} with a missing/empty namespace segment, or programmatic createSource/registerSource calls passing null namespace.

Common situations: Malformed REST URLs (only tenant given); scripts with unset NAMESPACE variables; SDK wrapper bugs defaulting namespace to null.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/fb67e177be8e5318. Report an issue: GitHub.