{"record":{"id":"d57e93d12d61b85b","repo":"hashicorp/nomad","slug":"numa-affinity-must-be-one-of-none-prefer-or-requ","errorCode":null,"errorMessage":"numa affinity must be one of none, prefer, or require","messagePattern":"numa affinity must be one of none, prefer, or require","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/numa.go","lineNumber":87,"sourceCode":"func (n *NUMA) Copy() *NUMA {\n\tif n == nil {\n\t\treturn nil\n\t}\n\treturn &NUMA{\n\t\tAffinity: n.Affinity,\n\t\tDevices:  slices.Clone(n.Devices),\n\t}\n}\n\nfunc (n *NUMA) Validate() error {\n\tif n == nil {\n\t\treturn nil\n\t}\n\tswitch n.Affinity {\n\tcase NoneNUMA, PreferNUMA, RequireNUMA:\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"numa affinity must be one of none, prefer, or require\")\n\t}\n}\n\n// Requested returns true if the NUMA.Affinity is set to one of \"prefer\" or\n// \"require\" and will require such CPU cores for scheduling.\nfunc (n *NUMA) Requested() bool {\n\tif n == nil || n.Affinity == NoneNUMA {\n\t\treturn false\n\t}\n\treturn true\n}\n\n// LegacyNodeCpuResources is the pre-1.7 CPU resources struct. It remains here\n// for compatibility and can be removed in Nomad 1.9+.\n//\n// Deprecated; use NodeProcessorResources instead.\ntype LegacyNodeCpuResources struct {\n\t// Deprecated; do not use this value except for compatibility.","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/numa.go#L69-L105","documentation":"The NUMA affinity field in a job's NUMA resource stanza only accepts the enumerated values 'none', 'prefer', or 'require'. Validate returns this error when Affinity holds any other string. It is a strict enum check to catch typos before scheduling.","triggerScenarios":"Submitting a job whose resources.cpu.numa.affinity stanza contains a value other than none/prefer/require (e.g. 'required', 'preferred', 'best-effort').","commonSituations":"Typos in job HCL; guessing value names instead of using the documented enum; configs carried over from other orchestrators with different NUMA option naming.","solutions":["Set numa.affinity to exactly one of none, prefer, or require","Remove the affinity field entirely (defaults to none)","Validate the job with nomad job validate before submitting"],"exampleFix":"// before\nnuma {\n  affinity = \"required\"\n}\n// after\nnuma {\n  affinity = \"require\"\n}","handlingStrategy":"validation","validationCode":"var validNUMA = map[string]bool{\"none\": true, \"prefer\": true, \"require\": true}\nif numa != nil && numa.Affinity != \"\" && !validNUMA[numa.Affinity] {\n    return fmt.Errorf(\"numa affinity %q invalid; must be none, prefer, or require\", numa.Affinity)\n}","typeGuard":"func validNUMAAffinity(a string) bool {\n    switch a { case \"\", \"none\", \"prefer\", \"require\": return true }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use only documented enum literals in job HCL","Run nomad job validate in CI before submitting jobs","Avoid hand-transcribing option names from other systems"],"tags":["nomad","numa","validation","enum"],"backgroundTag":"invalid-enum-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"}