apache/pulsar · error · RestException
maxSubscriptionsPerTopic must be 0 or more
Error message
maxSubscriptionsPerTopic must be 0 or more
What it means
Raised by internalSetMaxSubscriptionsPerTopic when the supplied maxSubscriptionsPerTopic value is negative; the namespace-policy write is rejected with 412 Precondition Failed before any policy update because the limit must be zero (unlimited) or a positive integer.
Source
Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2572
.attr("maxUnackedMessagesPerConsumer", maxUnackedMessagesPerConsumer)
.log("Successfully updated maxUnackedMessagesPerConsumer configuration");
} catch (RestException pfe) {
throw pfe;
} catch (Exception e) {
log.error()
.attr("namespace", namespaceName)
.exception(e)
.log("Failed to update maxUnackedMessagesPerConsumer configuration");
throw new RestException(e);
}
}
protected void internalSetMaxSubscriptionsPerTopic(Integer maxSubscriptionsPerTopic){
validateNamespacePolicyOperation(namespaceName, PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE);
validatePoliciesReadOnlyAccess();
if (maxSubscriptionsPerTopic != null && maxSubscriptionsPerTopic < 0) {
throw new RestException(Status.PRECONDITION_FAILED,
"maxSubscriptionsPerTopic must be 0 or more");
}
internalSetPolicies("max_subscriptions_per_topic", maxSubscriptionsPerTopic);
}
protected void internalSetMaxUnackedMessagesPerSubscription(Integer maxUnackedMessagesPerSubscription) {
validateNamespacePolicyOperation(namespaceName, PolicyName.MAX_UNACKED, PolicyOperation.WRITE);
validatePoliciesReadOnlyAccess();
if (maxUnackedMessagesPerSubscription != null && maxUnackedMessagesPerSubscription < 0) {
throw new RestException(Status.PRECONDITION_FAILED,
"maxUnackedMessagesPerSubscription must be 0 or more");
}
try {
updatePolicies(namespaceName, policies -> {
policies.max_unacked_messages_per_subscription = maxUnackedMessagesPerSubscription;
return policies;
});
log.info()View on GitHub (pinned to 820761864e)
Solutions
- Supply 0 (unlimited) or a positive subscription count
- Omit the field to leave the policy unchanged
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2572 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/61042d5a46e96222.
Report an issue: GitHub.