{"record":{"id":"cad30dd55330ae56","repo":"hashicorp/nomad","slug":"unit-can-not-be-specified-on-a-boolean-or-string-a","errorCode":null,"errorMessage":"unit can not be specified on a boolean or string attribute","messagePattern":"unit can not be specified on a boolean or string attribute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/shared/structs/attribute.go","lineNumber":254,"sourceCode":"\t}\n\n\tif a.Unit != \"\" {\n\t\tb.WriteString(a.Unit)\n\t}\n\n\treturn b.String()\n}\n\n// Validate checks if the attribute is valid\nfunc (a *Attribute) Validate() error {\n\tif a.Unit != \"\" {\n\t\tif _, ok := UnitIndex[a.Unit]; !ok {\n\t\t\treturn fmt.Errorf(\"unrecognized unit %q\", a.Unit)\n\t\t}\n\n\t\t// Check only int/float set\n\t\tif a.String != nil || a.Bool != nil {\n\t\t\treturn fmt.Errorf(\"unit can not be specified on a boolean or string attribute\")\n\t\t}\n\t}\n\n\t// Assert only one of the attributes is set\n\tset := 0\n\tif a.Float != nil {\n\t\tset++\n\t}\n\tif a.Int != nil {\n\t\tset++\n\t}\n\tif a.String != nil {\n\t\tset++\n\t}\n\tif a.Bool != nil {\n\t\tset++\n\t}\n","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/plugins/shared/structs/attribute.go#L236-L272","documentation":"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.","triggerScenarios":"Thrown at plugins/shared/structs/attribute.go:254 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the unit from string/boolean attributes","Keep units only on int or float attribute values"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}