{"record":{"id":"420fab1e29dd67ad","repo":"hashicorp/nomad","slug":"only-one-attribute-value-may-be-set","errorCode":null,"errorMessage":"only one attribute value may be set","messagePattern":"only one attribute value may be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/shared/structs/attribute.go","lineNumber":276,"sourceCode":"\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\n\tif set == 0 {\n\t\treturn fmt.Errorf(\"no attribute value set\")\n\t} else if set > 1 {\n\t\treturn fmt.Errorf(\"only one attribute value may be set\")\n\t}\n\n\treturn nil\n}\n\n// Comparable returns whether the two attributes are comparable\nfunc (a *Attribute) Comparable(b *Attribute) bool {\n\tif a == nil || b == nil {\n\t\treturn false\n\t}\n\n\t// First use the units to decide if comparison is possible\n\taUnit := a.getTypedUnit()\n\tbUnit := b.getTypedUnit()\n\tif aUnit != nil && bUnit != nil {\n\t\treturn aUnit.Comparable(bUnit)\n\t} else if aUnit != nil && bUnit == nil {\n\t\treturn false","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/plugins/shared/structs/attribute.go#L258-L294","documentation":"Attribute.Validate: more than one of the Float/Int/String/Bool value fields is set on the same attribute. Exactly one value may be present.","triggerScenarios":"Thrown at plugins/shared/structs/attribute.go:276 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set only one value field on the attribute","Clear the extra typed fields before validating"],"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"}