{"record":{"id":"5967fdf273c8e033","repo":"hashicorp/nomad","slug":"device-d-failed-validation-v","errorCode":null,"errorMessage":"device %d failed validation: %v","messagePattern":"device (.+?) failed validation: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":2444,"sourceCode":"\n\tif r.Cores < 0 {\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"cores value (%d) cannot be negative\", r.Cores))\n\t}\n\n\tif err := r.MeetsMinResources(); err != nil {\n\t\tmErr.Errors = append(mErr.Errors, err)\n\t}\n\n\t// Ensure the task isn't asking for disk resources\n\tif r.DiskMB > 0 {\n\t\tmErr.Errors = append(mErr.Errors, errors.New(\"Task can't ask for disk resources, they have to be specified at the task group level.\"))\n\t}\n\n\t// Ensure devices are valid\n\tdevices := set.New[string](len(r.Devices))\n\tfor i, d := range r.Devices {\n\t\tif err := d.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"device %d failed validation: %v\", i+1, err))\n\t\t}\n\t\tdevices.Insert(d.Name)\n\t}\n\n\t// Ensure each numa bound device matches a device requested for task\n\tif r.NUMA != nil {\n\t\tfor _, numaDevice := range r.NUMA.Devices {\n\t\t\tif !devices.Contains(numaDevice) {\n\t\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"numa device %q not requested as task resource\", numaDevice))\n\t\t\t}\n\t\t}\n\t}\n\n\t// Ensure the numa block is valid\n\tif err := r.NUMA.Validate(); err != nil {\n\t\tmErr.Errors = append(mErr.Errors, err)\n\t}\n","sourceCodeStart":2426,"sourceCodeEnd":2462,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L2426-L2462","documentation":"Resources.Validate iterates the task's device blocks and prefixes each device's own validation failure with its 1-based position. The underlying cause is reported by DeviceGroup.Validate (bad name, invalid attribute, etc.) for that indexed device request.","triggerScenarios":"Thrown at nomad/structs/structs.go:2444 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the offending device block and fix its fields (name, count, constraints, attributes)"],"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"}