hashicorp/nomad · error

device name must be given as one of the following: type, ven

Error message

device name must be given as one of the following: type, vendor/type, or vendor/type/name

What it means

DeviceRequest.Validate requires a non-empty Name formatted as type, vendor/type, or vendor/type/name (Consul/Nomad device plugin namespace convention, e.g. "gpu", "nvidia/gpu", "nvidia/gpu/gtx1080"). An empty or malformed device name fails validation.

Source

Thrown at nomad/structs/structs.go:3132

			Type:   parts[1],
		}
	default:
		return &DeviceIdTuple{
			Vendor: parts[0],
			Type:   parts[1],
			Name:   parts[2],
		}
	}
}

func (r *RequestedDevice) Validate() error {
	if r == nil {
		return nil
	}

	var mErr multierror.Error
	if r.Name == "" {
		_ = multierror.Append(&mErr, errors.New("device name must be given as one of the following: type, vendor/type, or vendor/type/name"))
	}

	for idx, constr := range r.Constraints {
		// Ensure that the constraint doesn't use an operand we do not allow
		switch constr.Operand {
		case ConstraintDistinctHosts, ConstraintDistinctProperty:
			outer := fmt.Errorf("Constraint %d validation failed: using unsupported operand %q", idx+1, constr.Operand)
			_ = multierror.Append(&mErr, outer)
		default:
			if err := constr.Validate(); err != nil {
				outer := fmt.Errorf("Constraint %d validation failed: %s", idx+1, err)
				_ = multierror.Append(&mErr, outer)
			}
		}
	}
	for idx, affinity := range r.Affinities {
		if err := affinity.Validate(); err != nil {
			outer := fmt.Errorf("Affinity %d validation failed: %s", idx+1, err)

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set the device name following the allowed formats, e.g. name = "gpu" or name = "nvidia/gpu"
  2. Match the name to what the device plugin exposes (vendor/type from plugin fingerprints)

Example fix

// before
devices {
  name = ""
}
// after
devices {
  name = "nvidia/gpu"
}
Defensive patterns

Strategy: validation

Validate before calling

const DEVICE_NAME_RE = /^[a-z0-9-]+(\/[a-z0-9-]+)?(\/[a-z0-9-]+)?$/i;
function validateDeviceName(dev) {
  if (!DEVICE_NAME_RE.test(dev.name ?? "")) {
    throw new Error(`device name must be type, vendor/type, or vendor/type/name; got "${dev.name}"`);
  }
}

Type guard

function hasValidDeviceName(d) { return typeof d.name === "string" && d.name.split("/").length <= 3 && d.name.length > 0; }

Try / catch

try {
  await nomad.jobs.validate(job);
} catch (e) {
  if (e.message.includes("device name must be given")) {
    console.error("Set device name like 'gpu', 'nvidia/gpu', or 'nvidia/gpu/gtx1080'");
  } else throw e;
}

Prevention

When it happens

Trigger: A resources { devices {} } block (DeviceRequest) whose name field is empty or does not follow the type[/vendor[/name]] shape when the job is validated.

Common situations: Omitting name when declaring device requests; typos like "nvidia" vendor-only paths are fine but empty strings are not; templating that leaves name blank.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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