apache/pulsar · error · RestException
maxTopicsPerNamespace must be 0 or more
Error message
maxTopicsPerNamespace must be 0 or more
What it means
Guard in internalSetMaxTopicsPerNamespace: the maxTopicsPerNamespace limit was negative, so the namespace-policy write fails with 412 Precondition Failed; zero means unlimited topics and the value must be zero or a positive integer.
Source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2977
log.error()
.attr("namespace", namespaceName)
.exception(e)
.log("Failed to remove offload configuration for namespace");
asyncResponse.resume(new RestException(e));
}
}
protected void internalRemoveMaxTopicsPerNamespace() {
validateNamespacePolicyOperation(namespaceName, PolicyName.MAX_TOPICS, PolicyOperation.WRITE);
internalSetMaxTopicsPerNamespace(null);
}
protected void internalSetMaxTopicsPerNamespace(Integer maxTopicsPerNamespace) {
validateNamespacePolicyOperation(namespaceName, PolicyName.MAX_TOPICS, PolicyOperation.WRITE);
validatePoliciesReadOnlyAccess();
if (maxTopicsPerNamespace != null && maxTopicsPerNamespace < 0) {
throw new RestException(Status.PRECONDITION_FAILED,
"maxTopicsPerNamespace must be 0 or more");
}
internalSetPolicies("max_topics_per_namespace", maxTopicsPerNamespace);
}
protected void internalSetProperty(String key, String value, AsyncResponse asyncResponse) {
validateAdminAccessForTenantAsync(namespaceName.getTenant())
.thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
.thenCompose(__ -> updatePoliciesAsync(namespaceName, policies -> {
policies.properties.put(key, value);
return policies;
}))
.thenAccept(v -> {
log.info()
.attr("key", key)
.attr("namespace", namespaceName)
.log("Successfully set property for key on namespace");
asyncResponse.resume(Response.noContent().build());View on GitHub (pinned to 820761864e)
Solutions
- Send a non-negative topic limit; 0 blocks new topic creation
- Use the remove endpoint to clear the limit instead of passing a negative number
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2977 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/56e6e1df15b71b29.
Report an issue: GitHub.