hashicorp/nomad · error

device failed validation

Error message

device %d failed validation: %v

What it means

Resources.Validate iterates the task's device blocks and prefixes each device's own validation failure with its 1-based position. The underlying cause is reported by DeviceGroup.Validate (bad name, invalid attribute, etc.) for that indexed device request.

Solutions

  1. Inspect the wrapped error for the offending device block and fix its fields (name, count, constraints, attributes)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nomad/structs/structs.go:2444 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at nomad/structs/structs.go:2444

	if r.Cores < 0 {
		mErr.Errors = append(mErr.Errors, fmt.Errorf("cores value (%d) cannot be negative", r.Cores))
	}

	if err := r.MeetsMinResources(); err != nil {
		mErr.Errors = append(mErr.Errors, err)
	}

	// Ensure the task isn't asking for disk resources
	if r.DiskMB > 0 {
		mErr.Errors = append(mErr.Errors, errors.New("Task can't ask for disk resources, they have to be specified at the task group level."))
	}

	// Ensure devices are valid
	devices := set.New[string](len(r.Devices))
	for i, d := range r.Devices {
		if err := d.Validate(); err != nil {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("device %d failed validation: %v", i+1, err))
		}
		devices.Insert(d.Name)
	}

	// Ensure each numa bound device matches a device requested for task
	if r.NUMA != nil {
		for _, numaDevice := range r.NUMA.Devices {
			if !devices.Contains(numaDevice) {
				mErr.Errors = append(mErr.Errors, fmt.Errorf("numa device %q not requested as task resource", numaDevice))
			}
		}
	}

	// Ensure the numa block is valid
	if err := r.NUMA.Validate(); err != nil {
		mErr.Errors = append(mErr.Errors, err)
	}

View on GitHub (pinned to 482b49bf1a)