{"record":{"id":"072e7bea8da9f967","repo":"hashicorp/nomad","slug":"dispatch-request-included-unpermitted-metadata-key","errorCode":null,"errorMessage":"Dispatch request included unpermitted metadata keys: %v","messagePattern":"Dispatch request included unpermitted metadata keys: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint.go","lineNumber":2174,"sourceCode":"\toptional := set.From(job.ParameterizedJob.MetaOptional)\n\n\t// Check the metadata key constraints are met\n\tunpermitted := make(map[string]struct{})\n\tfor k := range req.Meta {\n\t\treq := required.Contains(k)\n\t\topt := optional.Contains(k)\n\t\tif !req && !opt {\n\t\t\tunpermitted[k] = struct{}{}\n\t\t}\n\t}\n\n\tif len(unpermitted) != 0 {\n\t\tflat := make([]string, 0, len(unpermitted))\n\t\tfor k := range unpermitted {\n\t\t\tflat = append(flat, k)\n\t\t}\n\n\t\treturn fmt.Errorf(\"Dispatch request included unpermitted metadata keys: %v\", flat)\n\t}\n\n\tmissing := make(map[string]struct{})\n\tfor _, k := range job.ParameterizedJob.MetaRequired {\n\t\tif _, ok := req.Meta[k]; !ok {\n\t\t\tmissing[k] = struct{}{}\n\t\t}\n\t}\n\n\tif len(missing) != 0 {\n\t\tflat := make([]string, 0, len(missing))\n\t\tfor k := range missing {\n\t\t\tflat = append(flat, k)\n\t\t}\n\n\t\treturn fmt.Errorf(\"Dispatch did not provide required meta keys: %v\", flat)\n\t}\n","sourceCodeStart":2156,"sourceCodeEnd":2192,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint.go#L2156-L2192","documentation":"Parameterized jobs declare meta_required and meta_optional key lists. Any metadata key supplied in the dispatch that is in neither list is 'unpermitted' and causes rejection, keeping dispatch inputs strictly bounded by the job spec.","triggerScenarios":"Dispatching with meta keys not declared in the parameterized job's meta_required/meta_optional stanzas, e.g. `nomad job dispatch job key=val` where 'key' is undeclared.","commonSituations":"Job spec tightened (meta lists reduced) while callers still pass old keys; typos in meta key names; shared dispatch scripts passing job-specific keys to many parameterized jobs.","solutions":["Remove the unpermitted keys from the dispatch call","Add the keys to meta_optional (or meta_required) in the job's parameterized stanza and resubmit","Fix key-name typos so they match the declared lists"],"exampleFix":"// before (job declares meta_required=[\"run_id\"])\nnomad job dispatch batch-process run_id=7 bogus=1\n// after\nnomad job dispatch batch-process run_id=7","handlingStrategy":"validation","validationCode":"allowed := map[string]struct{}{}\nfor _, k := range append(job.ParameterizedJob.MetaRequired, job.ParameterizedJob.MetaOptional...) {\n    allowed[k] = struct{}{}\n}\nfor k := range meta {\n    if _, ok := allowed[k]; !ok {\n        return fmt.Errorf(\"meta key %q is not permitted for job %s\", k, jobID)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch the job's meta_required/meta_optional lists and filter meta client-side","Keep dispatch scripts in sync with the job spec's declared meta keys","Fail fast on typos by validating keys against the spec before submitting"],"tags":["nomad","api","metadata","parameterized-job","validation"],"backgroundTag":"unexpected-parameter","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"}