{"record":{"id":"7795df6eb47c1309","repo":"hashicorp/nomad","slug":"invalid-request-of-zero-devices","errorCode":null,"errorMessage":"invalid request of zero devices","messagePattern":"invalid request of zero devices","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scheduler/feasible/device.go","lineNumber":112,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false\n}\n\n// createOffer takes a device request and returns an assignment as well as a\n// score for the assignment. If no assignment is possible, an error is\n// returned explaining why.\nfunc (d *deviceAllocator) createOffer(mem *memoryNodeMatcher, ask *structs.RequestedDevice) (out *structs.AllocatedDeviceResource, score float64, err error) {\n\t// Try to hot path\n\tif len(d.Devices) == 0 {\n\t\treturn nil, 0.0, fmt.Errorf(\"no devices available\")\n\t}\n\tif ask.Count == 0 {\n\t\treturn nil, 0.0, fmt.Errorf(\"invalid request of zero devices\")\n\t}\n\n\t// Hold the current best offer\n\tvar offer *structs.AllocatedDeviceResource\n\tvar offerScore float64\n\tvar matchedWeights float64\n\n\t// Determine the devices that are feasible based on availability and\n\t// constraints\n\tfor id, devInst := range d.Devices {\n\t\t// Check if the device works\n\t\tif !nodeDeviceMatches(d.ctx, devInst.Device, ask) {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Check if we have enough unused instances to use this\n\t\tassignable := []string{}\n\t\tfor instanceID, v := range devInst.Instances {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/scheduler/feasible/device.go#L94-L130","documentation":"deviceAllocator.createOffer: the requested device count (ask.Count) is zero. Zero-count device requests are invalid — the block should be omitted entirely rather than asking for no devices.","triggerScenarios":"Thrown at scheduler/feasible/device.go:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the device request count to at least 1","Remove the device block from the task resources"],"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"}