{"record":{"id":"51e55cdba8f83b53","repo":"hashicorp/nomad","slug":"unknown-constraint-type-q","errorCode":null,"errorMessage":"Unknown constraint type %q","messagePattern":"Unknown constraint type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":10103,"sourceCode":"\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}\n\t\t}\n\n\t}\n\n\treturn mErr.ErrorOrNil()\n}\n","sourceCodeStart":10085,"sourceCodeEnd":10121,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L10085-L10121","documentation":"The constraint's Operand string does not match any operator Nomad recognizes (version, regex, is_set, comparison operators, set-contains, etc.), so it falls to the default case and is rejected as an unknown constraint type. Job submission fails validation.","triggerScenarios":"Submitting a job with a typo'd operand such as \"verison\", \"Version\", \"between\", or an operand removed/renamed in a newer Nomad version.","commonSituations":"Hand-written HCL with misspelled operand; migrating jobs between Nomad versions where an operand changed; using sugar fields (version/regexp/semver/distinct_property) incorrectly as operands; case-sensitivity mistakes.","solutions":["Correct the operand to a supported one: =, ==, is, !=, not, <, <=, >, >=, version, regex, semver, set_contains, set_contains_any, set_contains_all, is_set, is_not_set, distinct_property.","Use the job spec's sugar syntax (version = \">= 1.2\", regexp = \"...\") instead of raw operands where possible.","Run nomad job validate to catch the typo before submission."],"exampleFix":"// before\nconstraint {\n  attribute = \"${attr.kernel.version}\"\n  operand   = \"verison\"\n  value     = \">= 4.4\"\n}\n// after\nconstraint {\n  attribute = \"${attr.kernel.version}\"\n  version   = \">= 4.4\"\n}","handlingStrategy":"validation","validationCode":"var validOperands = map[string]bool{\n  \"=\": true, \"==\": true, \"is\": true, \"!=\": true, \"not\": true,\n  \"<\": true, \"<=\": true, \">\": true, \">=\": true,\n  \"version\": true, \"regex\": true, \"semver\": true,\n  \"set_contains\": true, \"set_contains_any\": true, \"set_contains_all\": true,\n  \"is_set\": true, \"is_not_set\": true, \"distinct_property\": true,\n}\n\nfunc validOperand(op string) bool { return validOperands[op] }","typeGuard":null,"tryCatchPattern":"if !validOperands[operand] {\n  return fmt.Errorf(\"unknown constraint operand %q\", operand)\n}","preventionTips":["Keep a checked list of supported operands in your job-generation code.","Prefer HCL sugar fields (version, regexp, semver) over raw operand strings.","Run nomad job validate on every rendered job."],"tags":["nomad","constraint","unknown-operator","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"}