{"record":{"id":"cef0f8050f7b4638","repo":"apache/rocketmq","slug":"maxnums-0","errorCode":null,"errorMessage":"maxNums <= 0","messagePattern":"maxNums <= 0","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java","lineNumber":1055,"sourceCode":"        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n        return this.pullSyncImpl(mq, subscriptionData, offset, maxNums, true, timeout);\n    }\n\n    private PullResult pullSyncImpl(MessageQueue mq, SubscriptionData subscriptionData, long offset, int maxNums,\n        boolean block,\n        long timeout)\n        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n\n        if (null == mq) {\n            throw new MQClientException(\"mq is null\", null);\n        }\n\n        if (offset < 0) {\n            throw new MQClientException(\"offset < 0\", null);\n        }\n\n        if (maxNums <= 0) {\n            throw new MQClientException(\"maxNums <= 0\", null);\n        }\n\n        int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false, true);\n\n        long timeoutMillis = block ? this.defaultLitePullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;\n\n        boolean isTagType = ExpressionType.isTagType(subscriptionData.getExpressionType());\n        PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(\n            mq,\n            subscriptionData.getSubString(),\n            subscriptionData.getExpressionType(),\n            isTagType ? 0L : subscriptionData.getSubVersion(),\n            offset,\n            maxNums,\n            sysFlag,\n            0,\n            this.defaultLitePullConsumer.getBrokerSuspendMaxTimeMillis(),\n            timeoutMillis,","sourceCodeStart":1037,"sourceCodeEnd":1073,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java#L1037-L1073","documentation":"pullSyncImpl throws MQClientException(\"maxNums <= 0\") when the batch size argument is zero or negative. maxNums bounds how many messages the broker may return in one pull; a non-positive value would request nothing and is rejected before the network call.","triggerScenarios":"consumer.pull(q, expr, offset, 0, timeout); passing a configurable pull batch size that defaults to 0 when unset.","commonSituations":"Batch size read from config with a missing default; arithmetic that divides/multiplies down to 0.","solutions":["Default the batch size to a positive value (e.g. 32) in configuration","Clamp: Math.max(1, configuredBatchSize) before calling pull"],"exampleFix":"// before\nconsumer.pull(q, \"*\", offset, config.getPullBatch(), 3000); // getPullBatch() may return 0\n\n// after\nint batch = Math.max(1, config.getPullBatch());\nconsumer.pull(q, \"*\", offset, batch, 3000);","handlingStrategy":"validation","validationCode":"int batch = Math.max(1, configuredPullBatchSize);\nPullResult r = consumer.pull(mq, expr, offset, batch, timeout);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give pull-batch-size config a positive default (e.g. 32)","Clamp externally supplied numeric configs at the boundary"],"tags":["rocketmq","consumer","pull","batch-size","validation"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}