{"record":{"id":"8ae58cf6166c0954","repo":"hashicorp/nomad","slug":"scaling-policy-invalid-task-group-count-must-not-8ae58c","errorCode":null,"errorMessage":"Scaling policy invalid: task group count must not be less than minimum count in scaling policy","messagePattern":"Scaling policy invalid: task group count must not be less than minimum count in scaling policy","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7631,"sourceCode":"\n\terr := tg.Scaling.Validate()\n\tif err != nil {\n\t\t// prefix scaling policy errors\n\t\tif me, ok := err.(*multierror.Error); ok {\n\t\t\tfor _, e := range me.Errors {\n\t\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Scaling policy invalid: %s\", e))\n\t\t\t}\n\t\t}\n\t}\n\n\tif tg.Scaling.Max < int64(tg.Count) {\n\t\tmErr.Errors = append(mErr.Errors,\n\t\t\tfmt.Errorf(\"Scaling policy invalid: task group count must not be greater than maximum count in scaling policy\"))\n\t}\n\n\tif int64(tg.Count) < tg.Scaling.Min && !(j.IsMultiregion() && tg.Count == 0 && j.Region == \"global\") {\n\t\tmErr.Errors = append(mErr.Errors,\n\t\t\tfmt.Errorf(\"Scaling policy invalid: task group count must not be less than minimum count in scaling policy\"))\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n\n// Warnings returns a list of warnings that may be from dubious settings or\n// deprecation warnings.\nfunc (tg *TaskGroup) Warnings(j *Job) error {\n\tvar mErr multierror.Error\n\n\t// Validate the update strategy\n\tif u := tg.Update; u != nil {\n\t\t// Check the counts are appropriate\n\t\tif tg.Count > 1 && u.MaxParallel > tg.Count && !(j.IsMultiregion() && tg.Count == 0) {\n\t\t\tmErr.Errors = append(mErr.Errors,\n\t\t\t\tfmt.Errorf(\"Update max parallel count is greater than task group count (%d > %d). \"+\n\t\t\t\t\t\"A destructive change would result in the simultaneous replacement of all allocations.\", u.MaxParallel, tg.Count))\n\t\t}","sourceCodeStart":7613,"sourceCodeEnd":7649,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7613-L7649","documentation":"Appended during task-group validation when the group's Count is below the scaling policy's minimum. The desired count must fit within the policy bounds; the multiregion global region with count 0 is the only exemption.","triggerScenarios":"Submitting a job with `count = N` while the `scaling` block has `min > N` (e.g. count=0, scaling min=2) in a non-exempt (non-multiregion-global) context.","commonSituations":"Setting count=0 to 'disable' a group that has a scaling policy with a nonzero min; raising min in an autoscaler policy after the job was already written.","solutions":["Raise the group `count` to be >= scaling min","Lower `min` in the scaling block","If intentionally scaling to zero, also lower the policy min to 0"],"exampleFix":"// before\ncount = 0\nscaling { min = 2 max = 5 }\n// after\ncount = 2\nscaling { min = 2 max = 5 }","handlingStrategy":"validation","validationCode":"if g.Scaling != nil && int64(g.Count) < g.Scaling.Min {\n  return fmt.Errorf(\"count %d below scaling.min %d\", g.Count, g.Scaling.Min)\n}","typeGuard":"func countAboveMin(g *api.TaskGroup) bool {\n  return g.Scaling == nil || int64(g.Count) >= g.Scaling.Min\n}","tryCatchPattern":null,"preventionTips":["Don't set count=0 on groups with nonzero scaling.min","Sync scaling.min when intentionally scaling down to zero","Validate jobs in CI to catch min/count drift"],"tags":["nomad","scaling-policy","job-validation"],"backgroundTag":"schema-validation-failed","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"}