{"record":{"id":"882b704ae13689fd","repo":"hashicorp/nomad","slug":"parameterized-job-can-only-be-used-with-q-or-q-s","errorCode":null,"errorMessage":"Parameterized job can only be used with %q or %q scheduler","messagePattern":"Parameterized job can only be used with %q or %q scheduler","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":4869,"sourceCode":"\t\t}\n\t}\n\n\t// Validate periodic is only used with batch or sysbatch jobs.\n\tif j.IsPeriodic() && j.Periodic.Enabled {\n\t\tif j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\n\t\t\t\t\"Periodic can only be used with %q or %q scheduler\", JobTypeBatch, JobTypeSysBatch,\n\t\t\t))\n\t\t}\n\n\t\tif err := j.Periodic.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t}\n\t}\n\n\tif j.IsParameterized() {\n\t\tif j.Type != JobTypeBatch && j.Type != JobTypeSysBatch {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\n\t\t\t\t\"Parameterized job can only be used with %q or %q scheduler\", JobTypeBatch, JobTypeSysBatch,\n\t\t\t))\n\t\t}\n\n\t\tif err := j.ParameterizedJob.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t}\n\t}\n\n\tif j.IsMultiregion() {\n\t\tif err := j.Multiregion.Validate(j.Type, j.Datacenters); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t}\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n","sourceCodeStart":4851,"sourceCodeEnd":4887,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L4851-L4887","documentation":"Job.Validate enforces that parameterized jobs (IsParameterized, i.e. a parameterized_job block is present) may only run under the batch or sysbatch scheduler. Otherwise the error 'Parameterized job can only be used with \"batch\" or \"sysbatch\" scheduler' is appended.","triggerScenarios":"Submitting a job containing a `parameterized_job` stanza while job type is \"service\", \"system\", or unset/derived to a non-batch type.","commonSituations":"Adding dispatch capability to an existing service job; scaffolding a dispatch job from a template that omitted type = \"batch\"; API clients setting ParameterizedJob on a structs.Job without adjusting Type.","solutions":["Set `type = \"batch\"` (or \"sysbatch\") on the parameterized job.","Or remove the `parameterized_job` block if dispatch semantics are not needed.","Validate with `nomad job validate` before submission."],"exampleFix":"// before\njob \"dispatch-me\" {\n  type = \"service\"\n  parameterized_job { payload = \"required\" }\n}\n// after\njob \"dispatch-me\" {\n  type = \"batch\"\n  parameterized_job { payload = \"required\" }\n}","handlingStrategy":"validation","validationCode":"if job.IsParameterized() &&\n   job.Type != \"batch\" && job.Type != \"sysbatch\" {\n    return fmt.Errorf(\"parameterized job must be type batch or sysbatch, got %q\", job.Type)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair every `parameterized_job` block with `type = \"batch\"`.","Use dispatch job templates that include the correct type.","Validate dispatch job specs as part of CI."],"tags":["nomad","parameterized-job","dispatch","job-validation"],"backgroundTag":"invalid-job-scheduler-type","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"}