{"record":{"id":"b5be7db3ea2bab1b","repo":"hashicorp/nomad","slug":"missing-scaling-policy-type","errorCode":null,"errorMessage":"missing scaling policy type","messagePattern":"missing scaling policy type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":6436,"sourceCode":"\t\tMax:         p.Max,\n\t\tCreateIndex: p.CreateIndex,\n\t\tModifyIndex: p.ModifyIndex,\n\t}\n\tc.Target = make(map[string]string, len(p.Target))\n\tmaps.Copy(c.Target, p.Target)\n\treturn &c\n}\n\nfunc (p *ScalingPolicy) Validate() error {\n\tif p == nil {\n\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","sourceCodeStart":6418,"sourceCodeEnd":6454,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L6418-L6454","documentation":"ScalingPolicy.Validate() collects errors into a multierror; if the policy's `type` field is empty, this error is appended. Every scaling policy must declare a type (currently `horizontal`) so Nomad knows which validation and scaling logic to apply.","triggerScenarios":"Submitting a job or scaling policy API object with a `scaling { }` block that omits the `policy { type = ... }` field, or an API-created ScalingPolicy with Type == \"\".","commonSituations":"Hand-written HCL missing `type = \"horizontal\"` inside the policy block; tooling generating policy JSON without the type key; upgrades from pre-scaling-API job formats.","solutions":["Add `type = \"horizontal\"` inside the scaling block's policy stanza.","Run `nomad job validate` to see the aggregated multierror and confirm remaining fields.","If registering policies via the API, ensure the JSON body includes `\"Type\": \"horizontal\"`."],"exampleFix":"// before\nscaling {\n  min = 1\n  max = 10\n  policy {}\n}\n// after\nscaling {\n  min = 1\n  max = 10\n  policy {\n    type = \"horizontal\"\n  }\n}","handlingStrategy":"validation","validationCode":"if policy.Type == \"\" {\n\treturn fmt.Errorf(\"scaling policy requires type = \\\"horizontal\\\"\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include `type = \"horizontal\"` in scaling policy stanzas.","Template new scaling blocks from the official Nomad docs example.","Add a lint rule in generated job JSON requiring the Type key on policies."],"tags":["nomad","scaling-policy","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"}