{"id":"f67b5fd6e6223495","repo":"docker/cli","slug":"invalid-rate-for-device-s-the-correct-format-is","errorCode":null,"errorMessage":"invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]. Number must be a positive integer. Unit is optional and can be kb, mb, or gb","messagePattern":"invalid rate for device: (.+?)\\. The correct format is <device-path>:<number>\\[<unit>\\]\\. Number must be a positive integer\\. Unit is optional and can be kb, mb, or gb","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/throttledevice.go","lineNumber":27,"sourceCode":"\t\"github.com/moby/moby/api/types/blkiodev\"\n)\n\n// ValidatorThrottleFctType defines a validator function that returns a validated struct and/or an error.\ntype ValidatorThrottleFctType func(val string) (*blkiodev.ThrottleDevice, error)\n\n// ValidateThrottleBpsDevice validates that the specified string has a valid device-rate format.\nfunc ValidateThrottleBpsDevice(val string) (*blkiodev.ThrottleDevice, error) {\n\tk, v, ok := strings.Cut(val, \":\")\n\tif !ok || k == \"\" {\n\t\treturn nil, fmt.Errorf(\"bad format: %s\", val)\n\t}\n\t// TODO(thaJeztah): should we really validate this on the client?\n\tif !strings.HasPrefix(k, \"/dev/\") {\n\t\treturn nil, fmt.Errorf(\"bad format for device path: %s\", val)\n\t}\n\trate, err := units.RAMInBytes(v)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]. Number must be a positive integer. Unit is optional and can be kb, mb, or gb\", val)\n\t}\n\tif rate < 0 {\n\t\treturn nil, fmt.Errorf(\"invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]. Number must be a positive integer. Unit is optional and can be kb, mb, or gb\", val)\n\t}\n\n\treturn &blkiodev.ThrottleDevice{\n\t\tPath: k,\n\t\tRate: uint64(rate),\n\t}, nil\n}\n\n// ValidateThrottleIOpsDevice validates that the specified string has a valid device-rate format.\nfunc ValidateThrottleIOpsDevice(val string) (*blkiodev.ThrottleDevice, error) {\n\tk, v, ok := strings.Cut(val, \":\")\n\tif !ok || k == \"\" {\n\t\treturn nil, fmt.Errorf(\"bad format: %s\", val)\n\t}\n\t// TODO(thaJeztah): should we really validate this on the client?","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/throttledevice.go#L9-L45","documentation":"Error \"invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]. Number must be a positive integer. Unit is optional and can be kb, mb, or gb\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/throttledevice.go:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}