hashicorp/nomad · error
unit can not be specified on a boolean or string attribute
Error message
unit can not be specified on a boolean or string attribute
What it means
Attribute.Validate: a unit was set on an attribute whose value is a string or boolean. Units only apply to numeric (float/int) attribute values.
Source
Thrown at plugins/shared/structs/attribute.go:254
}
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++
}
if a.Bool != nil {
set++
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Remove the unit from string/boolean attributes
- Keep units only on int or float attribute values
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at plugins/shared/structs/attribute.go:254 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/cad30dd55330ae56.
Report an issue: GitHub.