{"record":{"id":"9a0f940735454266","repo":"nats-io/nats-server","slug":"consumer-delivery-policy-is-deliver-s-but-option-9a0f94","errorCode":null,"errorMessage":"consumer delivery policy is deliver %s, but optional %s is not set","messagePattern":"consumer delivery policy is deliver (.+?), but optional (.+?) is not set","errorType":"validation","errorClass":"JSConsumerInvalidPolicyError","httpStatus":null,"severity":"error","filePath":"server/consumer.go","lineNumber":921,"sourceCode":"\n\t// Check subject filters do not overlap.\n\tfor outer, subject := range subjectFilters {\n\t\tif !IsValidSubject(subject) {\n\t\t\treturn NewJSStreamInvalidConfigError(ErrBadSubject)\n\t\t}\n\t\tfor inner, ssubject := range subjectFilters {\n\t\t\tif inner != outer && subjectIsSubsetMatch(subject, ssubject) {\n\t\t\t\treturn NewJSConsumerOverlappingSubjectFiltersError()\n\t\t\t}\n\t\t}\n\t}\n\n\t// Helper function to formulate similar errors.\n\tbadStart := func(dp, start string) error {\n\t\treturn fmt.Errorf(\"consumer delivery policy is deliver %s, but optional start %s is also set\", dp, start)\n\t}\n\tnotSet := func(dp, notSet string) error {\n\t\treturn fmt.Errorf(\"consumer delivery policy is deliver %s, but optional %s is not set\", dp, notSet)\n\t}\n\n\t// Check on start position conflicts.\n\tswitch config.DeliverPolicy {\n\tcase DeliverAll:\n\t\tif config.OptStartSeq > 0 {\n\t\t\treturn NewJSConsumerInvalidPolicyError(badStart(\"all\", \"sequence\"))\n\t\t}\n\t\tif config.OptStartTime != nil {\n\t\t\treturn NewJSConsumerInvalidPolicyError(badStart(\"all\", \"time\"))\n\t\t}\n\tcase DeliverLast:\n\t\tif config.OptStartSeq > 0 {\n\t\t\treturn NewJSConsumerInvalidPolicyError(badStart(\"last\", \"sequence\"))\n\t\t}\n\t\tif config.OptStartTime != nil {\n\t\t\treturn NewJSConsumerInvalidPolicyError(badStart(\"last\", \"time\"))\n\t\t}","sourceCodeStart":903,"sourceCodeEnd":939,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/consumer.go#L903-L939","documentation":"The inverse of the previous conflict: the chosen DeliverPolicy requires an optional start value that was not provided. The notSet helper returns this error naming the policy and the missing option — e.g. DeliverByStartSequence with OptStartSeq == 0, or DeliverByStartTime with a zero OptStartTime.","triggerScenarios":"ConsumerConfig with DeliverPolicy: DeliverByStartSequence but OptStartSeq left at 0; DeliverPolicy: DeliverByStartTime but OptStartTime unset (zero time).","commonSituations":"Setting only the deliver policy enum from CLI flags/UI and forgetting the matching start value; JSON payloads missing the optional field; defaults not filled in by an older client library.","solutions":["Supply the matching value: set OptStartSeq to the desired sequence when using DeliverByStartSequence, or OptStartTime when using DeliverByStartTime.","If you actually want everything, switch DeliverPolicy to DeliverAll instead of by-sequence/time.","Validate the consumer config client-side before submitting to catch the missing pairing early."],"exampleFix":"// before\ncc := nats.ConsumerConfig{DeliverPolicy: nats.DeliverByStartSequence}\n// after\ncc := nats.ConsumerConfig{DeliverPolicy: nats.DeliverByStartSequence, OptStartSeq: 1000}","handlingStrategy":"validation","validationCode":"func requiresStart(cc *nats.ConsumerConfig) error {\n    switch cc.DeliverPolicy {\n    case nats.DeliverByStartSequence:\n        if cc.OptStartSeq == 0 {\n            return fmt.Errorf(\"DeliverByStartSequence requires OptStartSeq\")\n        }\n    case nats.DeliverByStartTime:\n        if cc.OptStartTime.IsZero() {\n            return fmt.Errorf(\"DeliverByStartTime requires OptStartTime\")\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"_, err := js.AddConsumer(stream, cc)\nif err != nil && strings.Contains(err.Error(), \"is not set\") {\n    cc.DeliverPolicy = nats.DeliverAll // safe fallback\n    return js.AddConsumer(stream, cc)\n}","preventionTips":["Whenever you set DeliverByStartSequence/DeliverByStartTime, set the matching OptStartSeq/OptStartTime in the same place","Default to DeliverAll when no specific replay point is needed","Validate consumer config client-side before submitting"],"tags":["jetstream","consumer-config","validation"],"backgroundTag":"invalid-consumer-config","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}