hashicorp/nomad · error

unrecognized unit %q

Error message

unrecognized unit %q

What it means

Attribute.Validate: the attribute carries a Unit string that is not in the UnitIndex lookup of recognized units, so it cannot be interpreted for constraints or comparisons.

Source

Thrown at plugins/shared/structs/attribute.go:249

		b.WriteString(fmt.Sprintf("%v", *a.Int))
	} else if a.Bool != nil {
		b.WriteString(fmt.Sprintf("%v", *a.Bool))
	} else if a.String != nil {
		b.WriteString(*a.String)
	}

	if a.Unit != "" {
		b.WriteString(a.Unit)
	}

	return b.String()
}

// Validate checks if the attribute is valid
func (a *Attribute) Validate() error {
	if a.Unit != "" {
		if _, ok := UnitIndex[a.Unit]; !ok {
			return fmt.Errorf("unrecognized unit %q", a.Unit)
		}

		// Check only int/float set
		if a.String != nil || a.Bool != nil {
			return fmt.Errorf("unit can not be specified on a boolean or string attribute")
		}
	}

	// Assert only one of the attributes is set
	set := 0
	if a.Float != nil {
		set++
	}
	if a.Int != nil {
		set++
	}
	if a.String != nil {
		set++

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use a recognized unit from the UnitIndex set
  2. Omit the unit if the attribute does not need one
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at plugins/shared/structs/attribute.go:249 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/a4c527ae0d0a7b85. Report an issue: GitHub.