{"record":{"id":"316831085979c5fa","repo":"nats-io/nats-server","slug":"unknown-consumer-action-v","errorCode":null,"errorMessage":"unknown consumer action: %v","messagePattern":"unknown consumer action: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/consumer.go","lineNumber":231,"sourceCode":"\tcase ActionUpdate:\n\t\treturn actionUpdateJSONBytes, nil\n\tcase ActionCreateOrUpdate:\n\t\treturn actionCreateOrUpdateJSONBytes, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"can not marshal %v\", a)\n\t}\n}\n\nfunc (a *ConsumerAction) UnmarshalJSON(data []byte) error {\n\tswitch string(data) {\n\tcase actionCreateJSONString:\n\t\t*a = ActionCreate\n\tcase actionUpdateJSONString:\n\t\t*a = ActionUpdate\n\tcase actionCreateOrUpdateJSONString:\n\t\t*a = ActionCreateOrUpdate\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown consumer action: %v\", string(data))\n\t}\n\treturn nil\n}\n\n// ConsumerNakOptions is for optional NAK values, e.g. delay.\ntype ConsumerNakOptions struct {\n\tDelay time.Duration `json:\"delay\"`\n}\n\n// PriorityPolicy determines policy for selecting messages based on priority.\ntype PriorityPolicy int\n\nconst (\n\t// No priority policy.\n\tPriorityNone PriorityPolicy = iota\n\t// Clients will get the messages only if certain criteria are specified.\n\tPriorityOverflow\n\t// Single client takes over handling of the messages, while others are on standby.","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/consumer.go#L213-L249","documentation":"ConsumerConfig.Action is deserialized from JSON via UnmarshalJSON; the value must be one of the known JSON strings (create / update / create_or_update). Any other string fails unmarshalling with this error, so an invalid Action in a consumer create/update request JSON is rejected at parse time.","triggerScenarios":"Posting consumer config JSON with \"action\": \"upsert\" (a commonly assumed alias that does not exist), a typo like \"creat\", wrong casing, or an Action field serialized as a number/bool instead of a recognized string.","commonSituations":"Migrating from other systems where \"upsert\" was the term; SDK/client version drift where new action values are sent to an older server; hand-written curl payloads for the $JS.API.CONSUMER.CREATE subjects.","solutions":["Use exactly one of the accepted JSON strings: the values mapped by ActionCreate/ActionUpdate/ActionCreateOrUpdate constants (\"create\", \"update\", \"create_or_update\").","Drop the action field entirely if you want default behavior instead of guessing an alias.","Check the NATS server version's consumer.go constants to confirm which action strings your server supports."],"exampleFix":"// before\n{\"durable_name\": \"d1\", \"action\": \"upsert\"}\n// after\n{\"durable_name\": \"d1\", \"action\": \"create_or_update\"}","handlingStrategy":"validation","validationCode":"validActions := map[string]bool{\"create\": true, \"update\": true, \"create_or_update\": true}\nif cfg.Action != \"\" && !validActions[cfg.Action] {\n    return fmt.Errorf(\"invalid action %q\", cfg.Action)\n}","typeGuard":"func isValidConsumerAction(s string) bool {\n    switch s {\n    case \"create\", \"update\", \"create_or_update\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"_, err := js.AddConsumer(stream, cfg)\nif err != nil && strings.Contains(err.Error(), \"unknown consumer action\") {\n    cfg.Action = \"\" // or \"create_or_update\"\n    return js.AddConsumer(stream, cfg)\n}","preventionTips":["Only send \"create\", \"update\", or \"create_or_update\" — never \"upsert\"","Use the typed Action constants from the client library instead of raw strings","Check your server version's accepted action strings when mixing versions"],"tags":["jetstream","json","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"}