{"id":"eaa88305ef2c7e53","repo":"docker/cli","slug":"bad-format-for-device-path-s","errorCode":null,"errorMessage":"bad format for device path: %s","messagePattern":"bad format for device path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/throttledevice.go","lineNumber":23,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/docker/go-units\"\n\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, \":\")","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/throttledevice.go#L5-L41","documentation":"Error \"bad format for device path: %s\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/throttledevice.go:23 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}