hashicorp/nomad · error

missing scaling policy type

Error message

missing scaling policy type

What it means

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.

Source

Thrown at nomad/structs/structs.go:6436

		Max:         p.Max,
		CreateIndex: p.CreateIndex,
		ModifyIndex: p.ModifyIndex,
	}
	c.Target = make(map[string]string, len(p.Target))
	maps.Copy(c.Target, p.Target)
	return &c
}

func (p *ScalingPolicy) Validate() error {
	if p == nil {
		return nil
	}

	var mErr multierror.Error

	// Check policy type and target
	if p.Type == "" {
		mErr.Errors = append(mErr.Errors, fmt.Errorf("missing scaling policy type"))
	} else {
		mErr.Errors = append(mErr.Errors, p.validateType().Errors...)
	}

	// Check Min and Max
	if p.Max < 0 {
		mErr.Errors = append(mErr.Errors,
			fmt.Errorf("maximum count must be specified and non-negative"))
	} else if p.Max < p.Min {
		mErr.Errors = append(mErr.Errors,
			fmt.Errorf("maximum count must not be less than minimum count"))
	}

	if p.Min < 0 {
		mErr.Errors = append(mErr.Errors,
			fmt.Errorf("minimum count must be specified and non-negative"))
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Add `type = "horizontal"` inside the scaling block's policy stanza.
  2. Run `nomad job validate` to see the aggregated multierror and confirm remaining fields.
  3. If registering policies via the API, ensure the JSON body includes `"Type": "horizontal"`.

Example fix

// before
scaling {
  min = 1
  max = 10
  policy {}
}
// after
scaling {
  min = 1
  max = 10
  policy {
    type = "horizontal"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

if policy.Type == "" {
	return fmt.Errorf("scaling policy requires type = \"horizontal\"")
}

Prevention

When it happens

Trigger: 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 == "".

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/b5be7db3ea2bab1b. Report an issue: GitHub.