{"record":{"id":"6a69514aa868e4a0","repo":"nats-io/nats-server","slug":"max-waiting-must-not-be-negative","errorCode":null,"errorMessage":"max_waiting must not be negative","messagePattern":"max_waiting must not be negative","errorType":"validation","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"server/consumer.go","lineNumber":622,"sourceCode":"\tJsDefaultMaxAckPending = 1000\n\t// JsDefaultPinnedTTL is the default grace period for the pinned consumer to send a new request before a new pin\n\t// is picked by a server.\n\tJsDefaultPinnedTTL = 2 * time.Minute\n)\n\n// Helper function to set consumer config defaults from above.\nfunc setConsumerConfigDefaults(config *ConsumerConfig, streamCfg *StreamConfig, lim *JSLimitOpts, accLim *JetStreamAccountLimits, pedantic bool) *ApiError {\n\t// Setup default of -1, meaning no limit for MaxDeliver.\n\tif config.MaxDeliver == 0 || config.MaxDeliver < -1 {\n\t\tif pedantic && config.MaxDeliver < -1 {\n\t\t\treturn NewJSPedanticError(errors.New(\"max_deliver must be set to -1\"))\n\t\t}\n\t\tconfig.MaxDeliver = -1\n\t}\n\t// Setup zero defaults.\n\tif config.MaxWaiting < 0 {\n\t\tif pedantic {\n\t\t\treturn NewJSPedanticError(errors.New(\"max_waiting must not be negative\"))\n\t\t}\n\t\tconfig.MaxWaiting = 0\n\t}\n\tif config.MaxAckPending < -1 {\n\t\tif pedantic {\n\t\t\treturn NewJSPedanticError(errors.New(\"max_ack_pending must be set to -1\"))\n\t\t}\n\t\tconfig.MaxAckPending = -1\n\t}\n\tif config.MaxRequestBatch < 0 {\n\t\tif pedantic {\n\t\t\treturn NewJSPedanticError(errors.New(\"max_batch must not be negative\"))\n\t\t}\n\t\tconfig.MaxRequestBatch = 0\n\t}\n\tif config.MaxRequestExpires < 0 {\n\t\tif pedantic {\n\t\t\treturn NewJSPedanticError(errors.New(\"max_expires must not be negative\"))","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/consumer.go#L604-L640","documentation":"Consumer config validation: MaxWaiting (bound on outstanding pull requests for a pull consumer) was given a negative value, which is meaningless as a bound. The MaxWaiting field of the consumer create/update request is the input at fault.","triggerScenarios":"Thrown at server/consumer.go:622 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set max_waiting to 0 (server default) or a positive number","Omit the field from the consumer configuration"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}