{"record":{"id":"61042d5a46e96222","repo":"apache/pulsar","slug":"maxsubscriptionspertopic-must-be-0-or-more","errorCode":null,"errorMessage":"maxSubscriptionsPerTopic must be 0 or more","messagePattern":"maxSubscriptionsPerTopic must be 0 or more","errorType":"validation","errorClass":"RestException","httpStatus":412,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java","lineNumber":2572,"sourceCode":"                    .attr(\"maxUnackedMessagesPerConsumer\", maxUnackedMessagesPerConsumer)\n                    .log(\"Successfully updated maxUnackedMessagesPerConsumer configuration\");\n\n        } catch (RestException pfe) {\n            throw pfe;\n        } catch (Exception e) {\n            log.error()\n                    .attr(\"namespace\", namespaceName)\n                    .exception(e)\n                    .log(\"Failed to update maxUnackedMessagesPerConsumer configuration\");\n            throw new RestException(e);\n        }\n    }\n\n    protected void internalSetMaxSubscriptionsPerTopic(Integer maxSubscriptionsPerTopic){\n        validateNamespacePolicyOperation(namespaceName, PolicyName.MAX_SUBSCRIPTIONS, PolicyOperation.WRITE);\n        validatePoliciesReadOnlyAccess();\n        if (maxSubscriptionsPerTopic != null && maxSubscriptionsPerTopic < 0) {\n            throw new RestException(Status.PRECONDITION_FAILED,\n                    \"maxSubscriptionsPerTopic must be 0 or more\");\n        }\n        internalSetPolicies(\"max_subscriptions_per_topic\", maxSubscriptionsPerTopic);\n    }\n\n    protected void internalSetMaxUnackedMessagesPerSubscription(Integer maxUnackedMessagesPerSubscription) {\n        validateNamespacePolicyOperation(namespaceName, PolicyName.MAX_UNACKED, PolicyOperation.WRITE);\n        validatePoliciesReadOnlyAccess();\n        if (maxUnackedMessagesPerSubscription != null && maxUnackedMessagesPerSubscription < 0) {\n            throw new RestException(Status.PRECONDITION_FAILED,\n                    \"maxUnackedMessagesPerSubscription must be 0 or more\");\n        }\n        try {\n            updatePolicies(namespaceName, policies -> {\n                policies.max_unacked_messages_per_subscription = maxUnackedMessagesPerSubscription;\n                return policies;\n            });\n            log.info()","sourceCodeStart":2554,"sourceCodeEnd":2590,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L2554-L2590","documentation":"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.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2572 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply 0 (unlimited) or a positive subscription count","Omit the field to leave the policy unchanged"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}