{"record":{"id":"79a52c9b333a4d35","repo":"hashicorp/nomad","slug":"unknown-payload-requirement-q","errorCode":null,"errorMessage":"Unknown payload requirement: %q","messagePattern":"Unknown payload requirement: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":6089,"sourceCode":"\n// ParameterizedJobConfig is used to configure the parameterized job\ntype ParameterizedJobConfig struct {\n\t// Payload configure the payload requirements\n\tPayload string\n\n\t// MetaRequired is metadata keys that must be specified by the dispatcher\n\tMetaRequired []string\n\n\t// MetaOptional is metadata keys that may be specified by the dispatcher\n\tMetaOptional []string\n}\n\nfunc (d *ParameterizedJobConfig) Validate() error {\n\tvar mErr multierror.Error\n\tswitch d.Payload {\n\tcase DispatchPayloadOptional, DispatchPayloadRequired, DispatchPayloadForbidden:\n\tdefault:\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Unknown payload requirement: %q\", d.Payload))\n\t}\n\n\t// Check that the meta configurations are disjoint sets\n\tdisjoint, offending := helper.IsDisjoint(d.MetaRequired, d.MetaOptional)\n\tif !disjoint {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"Required and optional meta keys should be disjoint. Following keys exist in both: %v\", offending))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\nfunc (d *ParameterizedJobConfig) Canonicalize() {\n\tif d.Payload == \"\" {\n\t\td.Payload = DispatchPayloadOptional\n\t}\n}\n\nfunc (d *ParameterizedJobConfig) Copy() *ParameterizedJobConfig {","sourceCodeStart":6071,"sourceCodeEnd":6107,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L6071-L6107","documentation":"ParameterizedJobConfig.Validate checks that the dispatch payload requirement is one of the allowed constants: DispatchPayloadOptional, DispatchPayloadRequired, or DispatchPayloadForbidden. Any other value produces this error appended to the validation multierror. It guards the parameterized job's `dispatch_payload` configuration.","triggerScenarios":"Submitting a parameterized (dispatch) job where the payload policy field is set to a string other than \"optional\", \"required\", or \"forbidden\" — e.g. \"maybe\", \"Optional\" (wrong case), or a leftover value from a custom template.","commonSituations":"Hand-editing parameterized job templates; guessing valid values instead of consulting docs; case-sensitivity mistakes; copying configs between systems with different vocabularies.","solutions":["Set the payload value to exactly one of \"optional\", \"required\", or \"forbidden\".","Remove the field to rely on the default behavior if unsure.","Run `nomad job validate` to catch the invalid value before registration.","Check string casing — matching is exact."],"exampleFix":"// before\ndispatch_payload {\n  payload = \"Maybe\"\n}\n// after\ndispatch_payload {\n  payload = \"required\"\n}","handlingStrategy":"validation","validationCode":"func validPayload(p string) bool {\n    switch p {\n    case \"\", \"optional\", \"required\", \"forbidden\":\n        return true\n    default:\n        return false\n    }\n}\n// call before submitting: if !validPayload(job.ParameterizedJob.Payload) { ... }","typeGuard":null,"tryCatchPattern":"if err := job.ParameterizedJob.Validate(); err != nil {\n    // correct payload value and resubmit\n}","preventionTips":["Use the structs constants (DispatchPayloadOptional/Required/Forbidden) in Go code.","Only write the lowercase literals \"optional\"/\"required\"/\"forbidden\" in HCL.","Omit the field when the default is fine.","Run nomad job validate as a pre-submit gate."],"tags":["nomad","validation","dispatch","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}