{"record":{"id":"62c5d02d77c9a748","repo":"hashicorp/nomad","slug":"payload-is-not-provided-but-required-by-parameteri","errorCode":null,"errorMessage":"Payload is not provided but required by parameterized job","messagePattern":"Payload is not provided but required by parameterized job","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint.go","lineNumber":2136,"sourceCode":"\treply.JobCreateIndex = jobCreateIndex\n\treply.DispatchedJobID = dispatchJob.ID\n\treply.Index = jobCreateIndex\n\n\tif eval != nil {\n\t\treply.EvalID = eval.ID\n\t\treply.EvalCreateIndex = jobCreateIndex\n\t}\n\n\treturn nil\n}\n\n// validateDispatchRequest returns whether the request is valid given the\n// parameterized job.\nfunc validateDispatchRequest(req *structs.JobDispatchRequest, job *structs.Job, config *Config) error {\n\t// Check the payload constraint is met\n\thasInputData := len(req.Payload) != 0\n\tif job.ParameterizedJob.Payload == structs.DispatchPayloadRequired && !hasInputData {\n\t\treturn fmt.Errorf(\"Payload is not provided but required by parameterized job\")\n\t} else if job.ParameterizedJob.Payload == structs.DispatchPayloadForbidden && hasInputData {\n\t\treturn fmt.Errorf(\"Payload provided but forbidden by parameterized job\")\n\t}\n\n\t// Check the payload doesn't exceed the size limit\n\tif l := len(req.Payload); l > DispatchPayloadSizeLimit {\n\t\treturn fmt.Errorf(\"Payload exceeds maximum size; %d > %d\", l, DispatchPayloadSizeLimit)\n\t}\n\n\t// Check if the metadata is a set\n\tkeys := make(map[string]struct{}, len(req.Meta))\n\tfor k := range req.Meta {\n\t\tif _, ok := keys[k]; ok {\n\t\t\treturn fmt.Errorf(\"Duplicate key %q in passed metadata\", k)\n\t\t}\n\t\tkeys[k] = struct{}{}\n\t}\n","sourceCodeStart":2118,"sourceCodeEnd":2154,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint.go#L2118-L2154","documentation":"validateDispatchRequest enforces the parameterized job's payload constraint. If the job declares payload = \"required\" in its parameterized stanza but the dispatch request carries no (empty) payload, the dispatch is rejected.","triggerScenarios":"Dispatching a parameterized job with `parameterized { payload = \"required\" }` while passing an empty Payload in JobDispatchRequest (or no stdin/body via `nomad job dispatch`).","commonSituations":"CLI dispatch invoked without piping payload data (`nomad job dispatch job` with no stdin); automation that omits the payload for jobs recently switched from optional to required.","solutions":["Provide a payload: `echo <data> | nomad job dispatch <job-id>` or set Payload in the request","If payload is unnecessary, change the job spec to `payload = \"optional\"` or \"forbidden\" and resubmit","Update automation to always attach required payload bytes"],"exampleFix":"// before\nnomad job dispatch batch-process\n// after\necho '{\"input\":true}' | nomad job dispatch batch-process","handlingStrategy":"validation","validationCode":"if *job.ParameterizedJob.Payload == \"required\" && len(payload) == 0 {\n    return fmt.Errorf(\"job %s requires a payload\", jobID)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the job's ParameterizedJob.Payload before dispatching","In CLI scripts, always pipe stdin when the job requires payload","Track job spec changes (required vs optional) alongside dispatch automation"],"tags":["nomad","api","payload","parameterized-job","validation"],"backgroundTag":"missing-required-argument","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"}