apache/pulsar · error · RestException
Namespace is not provided
Error message
Namespace is not provided
What it means
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.
Source
Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SinksImpl.java:94
@Override
public void registerSink(final String tenant,
final String namespace,
final String sinkName,
final InputStream uploadedInputStream,
final FormDataContentDisposition fileDetail,
final String sinkPkgUrl,
final SinkConfig sinkConfig,
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 (sinkName == null) {
throw new RestException(Response.Status.BAD_REQUEST, "Sink name is not provided");
}
if (sinkConfig == null) {
throw new RestException(Response.Status.BAD_REQUEST, "Sink config is not provided");
}
throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, sinkName, "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
- 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.
Example fix
// before
sinks.registerSink(tenant, null, sinkName, ...);
// after
if (namespace == null || namespace.isBlank()) {
throw new IllegalArgumentException("namespace is required");
}
sinks.registerSink(tenant, namespace, sinkName, ...); Defensive patterns
Strategy: validation
Validate before calling
if (namespace == null || namespace.isBlank()) {
throw new IllegalArgumentException("namespace must be provided");
} Type guard
boolean hasNamespace(String namespace) {
return namespace != null && !namespace.isBlank();
} Try / catch
try {
sinks.registerSink(tenant, ns, name, cfg, null, null, null, authParams);
} catch (RestException e) {
if (e.getResponse().getStatus() == 400 && "Namespace is not provided".equals(e.getMessage())) {
// supply namespace and retry
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: Calling the sink registration endpoint with namespace=null: missing namespace path segment in the URL, or a null namespace passed to SinksImpl.registerSink.
Common situations: 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.
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
- Tenant is not provided
- Sink name is not provided
- Sink config is not provided
- <validation message from IllegalArgumentException>
- Path key doesn't match key in json
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/aa8b6f0aabc4e35b.
Report an issue: GitHub.