hashicorp/nomad · error

device type must be specified

Error message

device type must be specified

What it means

Appended by DeviceGroup.Validate() when the device group's Type field is empty. Nomad requires a canonical device type (e.g. "gpu", plugins/device/device.go DeviceTypeGPU) so schedulers can match task device requests to fingerprinted groups.

Source

Thrown at plugins/device/device.go:95

	// Name is the devices model name.
	Name string

	// Devices is the set of device instances.
	Devices []*Device

	// Attributes are a set of attributes shared for all the devices.
	Attributes map[string]*structs.Attribute
}

// Validate validates that the device group is valid
func (d *DeviceGroup) Validate() error {
	var mErr multierror.Error

	if d.Vendor == "" {
		_ = multierror.Append(&mErr, fmt.Errorf("device vendor must be specified"))
	}
	if d.Type == "" {
		_ = multierror.Append(&mErr, fmt.Errorf("device type must be specified"))
	}
	if d.Name == "" {
		_ = multierror.Append(&mErr, fmt.Errorf("device name must be specified"))
	}

	for i, dev := range d.Devices {
		if dev == nil {
			_ = multierror.Append(&mErr, fmt.Errorf("device %d is nil", i))
			continue
		}

		if err := dev.Validate(); err != nil {
			_ = multierror.Append(&mErr, multierror.Prefix(err, fmt.Sprintf("device %d: ", i)))
		}
	}

	for k, v := range d.Attributes {
		if err := v.Validate(); err != nil {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set Type to a canonical constant such as device.DeviceTypeGPU ("gpu") in the plugin's DeviceGroup and restart
  2. Fix the plugin's configuration so the device type is provided during fingerprinting
  3. Call Validate() in the plugin before publishing groups to fail fast with the multierror details

Example fix

// before
var t string
// after
t := device.DeviceTypeGPU // "gpu"
g := &device.DeviceGroup{Vendor: "nvidia", Type: t, Name: "k80"}
Defensive patterns

Strategy: validation

Validate before calling

// Go: guard before returning a DeviceGroup
if g.Type == "" {
    return nil, fmt.Errorf("device group %s/%s missing type", g.Vendor, g.Name)
}

Prevention

When it happens

Trigger: Fingerprinting returns a DeviceGroup with Type == "" and Validate() is called; or a plugin sets a type that is empty rather than a canonical DeviceType* constant.

Common situations: Custom device plugin not setting Type; plugin config missing the device-type option; refactored plugin code dropping the field.

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/02e57c7d29c909a2. Report an issue: GitHub.