{"record":{"id":"959b81a52139e46b","repo":"apache/pulsar","slug":"maxunackedmessagespersubscription-must-be-0-or-mor","errorCode":null,"errorMessage":"maxUnackedMessagesPerSubscription must be 0 or more","messagePattern":"maxUnackedMessagesPerSubscription 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":2582,"sourceCode":"            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()\n                    .attr(\"namespace\", namespaceName)\n                    .attr(\"maxUnackedMessagesPerSubscription\", maxUnackedMessagesPerSubscription)\n                    .log(\"Successfully updated maxUnackedMessagesPerSubscription configuration\");\n\n        } catch (RestException pfe) {\n            throw pfe;\n        } catch (Exception e) {\n            log.error()\n                    .attr(\"namespace\", namespaceName)\n                    .exception(e)","sourceCodeStart":2564,"sourceCodeEnd":2600,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L2564-L2600","documentation":"Guard in the maxUnackedMessagesPerSubscription setter: a negative value was passed for the namespace anti-backlog limit, so the update is rejected with 412 Precondition Failed before policies are persisted; zero disables the cap and positive values set it.","triggerScenarios":"Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:2582 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a non-negative integer (0 means no limit) for maxUnackedMessagesPerSubscription","Check the request body for a sign error or corrupted numeric field"],"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-14T05:17:10.506Z"}