{"record":{"id":"3d414d2f3f3693f2","repo":"hashicorp/nomad","slug":"maximum-count-must-not-be-less-than-minimum-count","errorCode":null,"errorMessage":"maximum count must not be less than minimum count","messagePattern":"maximum count must not be less than minimum count","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":6447,"sourceCode":"\t\treturn nil\n\t}\n\n\tvar mErr multierror.Error\n\n\t// Check policy type and target\n\tif p.Type == \"\" {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"missing scaling policy type\"))\n\t} else {\n\t\tmErr.Errors = append(mErr.Errors, p.validateType().Errors...)\n\t}\n\n\t// Check Min and Max\n\tif p.Max < 0 {\n\t\tmErr.Errors = append(mErr.Errors,\n\t\t\tfmt.Errorf(\"maximum count must be specified and non-negative\"))\n\t} else if p.Max < p.Min {\n\t\tmErr.Errors = append(mErr.Errors,\n\t\t\tfmt.Errorf(\"maximum count must not be less than minimum count\"))\n\t}\n\n\tif p.Min < 0 {\n\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] == \"\" {","sourceCodeStart":6429,"sourceCodeEnd":6465,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L6429-L6465","documentation":"ScalingPolicy.Validate() requires max >= min. When the policy's Max is non-negative but strictly less than Min, this error is appended to the multierror. The count range would otherwise be contradictory (the scaler could never move within it).","triggerScenarios":"Submitting a scaling block like `min = 5, max = 2`, or swapping the values when copying an example, or updating max downward below the current min via the scaling policy API.","commonSituations":"Copy-paste mistakes in HCL; autoscaler configs edited manually where min was raised later and max was not; templated jobs with reversed interpolation of min/max variables.","solutions":["Raise `max` to be greater than or equal to `min`.","Lower `min` if it was set too high relative to the intended max.","Run `nomad job validate` after the fix to confirm no other policy errors remain."],"exampleFix":"// before\nscaling {\n  min = 5\n  max = 2\n}\n// after\nscaling {\n  min = 2\n  max = 5\n}","handlingStrategy":"validation","validationCode":"if policy.Min >= 0 && policy.Max >= 0 && policy.Max < policy.Min {\n\treturn fmt.Errorf(\"max (%d) must be >= min (%d)\", policy.Max, policy.Min)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce min <= max in any tooling that writes scaling blocks.","When lowering max via the autoscaler, first lower or check min.","Keep min/max as paired (min,max) variables to avoid swapped values."],"tags":["nomad","scaling-policy","validation"],"backgroundTag":"invalid-numeric-range","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"}