{"record":{"id":"4e5744d6e01bc1ca","repo":"hashicorp/nomad","slug":"missing-target-job","errorCode":null,"errorMessage":"missing target job","messagePattern":"missing target job","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":6469,"sourceCode":"\t\tmErr.Errors = append(mErr.Errors,\n\t\t\tfmt.Errorf(\"minimum count must be specified and non-negative\"))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\nfunc (p *ScalingPolicy) validateTargetHorizontal() (mErr multierror.Error) {\n\tif len(p.Target) == 0 {\n\t\t// This is probably not a Nomad horizontal policy\n\t\treturn\n\t}\n\n\t// Nomad horizontal policies should have Namespace, Job and TaskGroup\n\tif p.Target[ScalingTargetNamespace] == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"missing target namespace\"))\n\t}\n\tif p.Target[ScalingTargetJob] == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"missing target job\"))\n\t}\n\tif p.Target[ScalingTargetGroup] == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"missing target group\"))\n\t}\n\treturn\n}\n\n// Diff indicates whether the specification for a given scaling policy has changed\nfunc (p *ScalingPolicy) Diff(p2 *ScalingPolicy) bool {\n\tcopy := *p2\n\tcopy.ID = p.ID\n\tcopy.CreateIndex = p.CreateIndex\n\tcopy.ModifyIndex = p.ModifyIndex\n\treturn !reflect.DeepEqual(*p, copy)\n}\n\nfunc (p *ScalingPolicy) Stub() *ScalingPolicyListStub {\n\tstub := &ScalingPolicyListStub{","sourceCodeStart":6451,"sourceCodeEnd":6487,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L6451-L6487","documentation":"ScalingPolicy.validateTargetHorizontal() requires a non-empty `Job` key in the target map for horizontal policies. The job identifies which job the scaling policy applies to; its absence triggers this error alongside (potentially) the namespace/group checks.","triggerScenarios":"Submitting a horizontal scaling policy with a target block that has `namespace` and `group` but omits `job`, or an API Target map missing the ScalingTargetJob key.","commonSituations":"Copy-pasting policy templates that omit the job key; tooling building Target maps from partial context; renaming a job and dropping the key during refactoring.","solutions":["Add `job = \"<job-name>\"` inside the policy's target block.","Ensure the job name matches the job the policy is registered under.","Re-validate the policy after adding the key."],"exampleFix":"// before\ntarget {\n  namespace = \"default\"\n  group     = \"frontend\"\n}\n// after\ntarget {\n  namespace = \"default\"\n  job       = \"web\"\n  group     = \"frontend\"\n}","handlingStrategy":"validation","validationCode":"if policy.Target[\"Job\"] == \"\" {\n\treturn fmt.Errorf(\"horizontal policy target missing Job\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set `job` explicitly in every horizontal policy target block.","When renaming jobs, update target.job in registered scaling policies.","Check for all three target keys (Namespace/Job/TaskGroup) in policy-generation tooling."],"tags":["nomad","scaling-policy","target","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"}