{"record":{"id":"d06e8872aca3f53d","repo":"nats-io/nats-server","slug":"unknown-priority-policy-v","errorCode":null,"errorMessage":"unknown priority policy: %v","messagePattern":"unknown priority policy: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/consumer.go","lineNumber":308,"sourceCode":"\tcase PriorityNone:\n\t\treturn PriorityNoneJSONBytes, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown priority policy: %v\", pp)\n\t}\n}\n\nfunc (pp *PriorityPolicy) UnmarshalJSON(data []byte) error {\n\tswitch string(data) {\n\tcase PriorityOverflowJSONString:\n\t\t*pp = PriorityOverflow\n\tcase PriorityPinnedClientJSONString:\n\t\t*pp = PriorityPinnedClient\n\tcase PriorityPrioritizedJSONString:\n\t\t*pp = PriorityPrioritized\n\tcase PriorityNoneJSONString:\n\t\t*pp = PriorityNone\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown priority policy: %v\", string(data))\n\t}\n\treturn nil\n}\n\n// DeliverPolicy determines how the consumer should select the first message to deliver.\ntype DeliverPolicy int\n\nconst (\n\t// DeliverAll will be the default so can be omitted from the request.\n\tDeliverAll DeliverPolicy = iota\n\t// DeliverLast will start the consumer with the last sequence received.\n\tDeliverLast\n\t// DeliverNew will only deliver new messages that are sent after the consumer is created.\n\tDeliverNew\n\t// DeliverByStartSequence will look for a defined starting sequence to start.\n\tDeliverByStartSequence\n\t// DeliverByStartTime will select the first messsage with a timestamp >= to StartTime.\n\tDeliverByStartTime","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/consumer.go#L290-L326","documentation":"ConsumerConfig.PriorityPolicy is validated when deserializing its JSON representation; only the recognized JSON strings (mapped to PriorityPinnedClient, PriorityPrioritized, PriorityNone) are accepted. Any other string returns this error during unmarshalling.","triggerScenarios":"Consumer config JSON containing \"priority_policy\": \"overflow\" or \"pinned\" or any string not exactly matching the PriorityPinnedClient/Prioritized/None JSON constants, or a non-string value.","commonSituations":"Copying examples from blog posts or newer client libraries that use different naming; enabling priority policies on a server whose accepted constants differ; typos in terraform/automation templates for JetStream consumers.","solutions":["Use one of the exact JSON strings accepted by the PriorityPolicy constants (pinned_client / prioritized / none style values defined in server/consumer.go).","Omit priority_policy (defaults to none) if you do not need priority delivery.","Confirm server version support: priority policies are a newer feature; older servers reject newer policy names."],"exampleFix":"// before\n{\"priority_policy\": \"pinned\"}\n// after\n{\"priority_policy\": \"pinned_client\"}","handlingStrategy":"validation","validationCode":"validPolicies := map[string]bool{\"pinned_client\": true, \"prioritized\": true, \"none\": true}\nif cfg.PriorityPolicy != \"\" && !validPolicies[cfg.PriorityPolicy] {\n    return fmt.Errorf(\"invalid priority_policy %q\", cfg.PriorityPolicy)\n}","typeGuard":"func isValidPriorityPolicy(s string) bool {\n    switch s {\n    case \"pinned_client\", \"prioritized\", \"none\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"_, err := js.AddConsumer(stream, cfg)\nif err != nil && strings.Contains(err.Error(), \"unknown priority policy\") {\n    cfg.PriorityPolicy = \"\" // fall back to default (none)\n    return js.AddConsumer(stream, cfg)\n}","preventionTips":["Copy policy strings from the server constants, not from third-party examples","Omit priority_policy unless you specifically need priority delivery","Verify feature support on your NATS server version before enabling priority policies"],"tags":["jetstream","json","validation"],"backgroundTag":"invalid-consumer-config","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}