{"record":{"id":"50b4623ed2b25d90","repo":"hashicorp/nomad","slug":"operator-q-does-not-support-an-rtarget","errorCode":null,"errorMessage":"Operator %q does not support an RTarget","messagePattern":"Operator %q does not support an RTarget","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":10096,"sourceCode":"\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Version constraint is invalid: %v\", err))\n\t\t}\n\tcase ConstraintSemver:\n\t\tif _, err := semver.NewConstraint(c.RTarget); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Semver constraint is invalid: %v\", err))\n\t\t}\n\tcase ConstraintDistinctProperty:\n\t\t// If a count is set, make sure it is convertible to a uint64\n\t\tif c.RTarget != \"\" {\n\t\t\tcount, err := strconv.ParseUint(c.RTarget, 10, 64)\n\t\t\tif err != nil {\n\t\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Failed to convert RTarget %q to uint64: %v\", c.RTarget, err))\n\t\t\t} else if count < 1 {\n\t\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Distinct Property must have an allowed count of 1 or greater: %d < 1\", count))\n\t\t\t}\n\t\t}\n\tcase ConstraintAttributeIsSet, ConstraintAttributeIsNotSet:\n\t\tif c.RTarget != \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Operator %q does not support an RTarget\", c.Operand))\n\t\t}\n\tcase \"=\", \"==\", \"is\", \"!=\", \"not\", \"<\", \"<=\", \">\", \">=\":\n\t\tif c.RTarget == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Operator %q requires an RTarget\", c.Operand))\n\t\t}\n\tdefault:\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Unknown constraint type %q\", c.Operand))\n\t}\n\n\t// If the constraint must have a \"LTarget\" (attribute in the job spec), then\n\t// ensure it is not an empty string and is valid.\n\tif requireLtarget {\n\t\tif c.LTarget == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, errors.New(\"no attribute provided but is required by operator\"))\n\t\t} else {\n\t\t\tif err := validateConstraintAttribute(c.LTarget); err != nil {\n\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t}","sourceCodeStart":10078,"sourceCodeEnd":10114,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L10078-L10114","documentation":"The constraint's operand is \"is_set\" or \"is_not_set\", which test only for attribute presence, but an RTarget (right-hand value) was supplied. These operators take no comparison value, so providing one is flagged as a validation error.","triggerScenarios":"Submitting a job with constraint { operand = \"is_set\" attribute = \"${meta.foo}\" ... } where an RTarget/value field is also set, e.g. value = \"bar\".","commonSituations":"Copy-pasting a comparison constraint and only changing the operand to is_set while leaving the old value; templated generation that always emits a value field; misunderstanding that is_set takes an argument.","solutions":["Remove the value/RTarget from the is_set / is_not_set constraint.","If you need a value comparison, use an equality operand (=, !=) instead of is_set.","Fix the generating template to omit the value field for these operands."],"exampleFix":"// before\nconstraint {\n  operand  = \"is_set\"\n  attribute = \"${meta.tls}\"\n  value    = \"true\"\n}\n// after\nconstraint {\n  operand   = \"is_set\"\n  attribute = \"${meta.tls}\"\n}","handlingStrategy":"validation","validationCode":"func constraintTargetAllowed(operand, rtarget string) bool {\n  switch operand {\n  case \"is_set\", \"is_not_set\":\n    return rtarget == \"\"\n  default:\n    return true\n  }\n}","typeGuard":null,"tryCatchPattern":"if (operand == \"is_set\" || operand == \"is_not_set\") && rtarget != \"\" {\n  return fmt.Errorf(\"operand %q must not have a value\", operand)\n}","preventionTips":["Never set the value field on is_set/is_not_set constraints.","Make job templates conditional on operand type when emitting value.","Review hand-edited HCL diffs for leftover value lines."],"tags":["nomad","constraint","operator-misuse","job-validation"],"backgroundTag":"invalid-constraint-operator-usage","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"}