{"record":{"id":"ccdadc54d2cc5066","repo":"hashicorp/nomad","slug":"failed-to-convert-rtarget-q-to-uint64-v","errorCode":null,"errorMessage":"Failed to convert RTarget %q to uint64: %v","messagePattern":"Failed to convert RTarget %q to uint64: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":10089,"sourceCode":"\t\t}\n\tcase ConstraintRegex:\n\t\tif _, err := regexp.Compile(c.RTarget); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Regular expression failed to compile: %v\", err))\n\t\t}\n\tcase ConstraintVersion:\n\t\tif _, err := version.NewConstraint(c.RTarget); err != nil {\n\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.","sourceCodeStart":10071,"sourceCodeEnd":10107,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L10071-L10107","documentation":"A \"distinct_property\" constraint's RTarget (the allowed count) was set but could not be parsed as an unsigned 64-bit integer via strconv.ParseUint. The count must be a plain non-negative integer string. The job fails validation and is rejected by the Nomad API.","triggerScenarios":"Submitting a job with constraint operand \"distinct_property\" and RTarget values like \"two\", \"2.0\", \"-1\", \"+3\", \"0x2\", or a value with whitespace.","commonSituations":"Quoting/escaping issues in HCL producing a non-numeric string; passing a float or negative count from templated job generation; copying examples that use a number literal where a string \"2\" is expected; locale-formatted numbers with thousand separators.","solutions":["Set the distinct_property count RTarget to a plain decimal integer string, e.g. \"2\".","Ensure the value has no sign, decimals, whitespace, or separators.","Pre-validate with strconv.ParseUint(target, 10, 64) before submitting."],"exampleFix":"// before\nconstraint {\n  attribute        = \"${attr.datacenter}\"\n  distinct_property = \"2.0\"\n}\n// after\nconstraint {\n  attribute         = \"${attr.datacenter}\"\n  distinct_property = \"2\"\n}","handlingStrategy":"validation","validationCode":"func validDistinctPropertyCount(target string) bool {\n  if target == \"\" { return true }\n  _, err := strconv.ParseUint(target, 10, 64)\n  return err == nil\n}","typeGuard":null,"tryCatchPattern":"count, err := strconv.ParseUint(target, 10, 64)\nif err != nil {\n  return fmt.Errorf(\"distinct_property count must be a plain integer, got %q\", target)\n}","preventionTips":["Emit counts as integer strings (\"2\") from templates, never floats or signed numbers.","Strip whitespace before submitting.","Add a schema check on the job-rendering side."],"tags":["nomad","constraint","distinct-property","parsing"],"backgroundTag":"invalid-constraint-value","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"}