{"record":{"id":"1518ccdf87dbdef0","repo":"docker/cli","slug":"bad-format-s-1518cc","errorCode":null,"errorMessage":"bad format: %s","messagePattern":"bad format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/weightdevice.go","lineNumber":18,"sourceCode":"package opts\n\nimport (\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/moby/moby/api/types/blkiodev\"\n)\n\n// ValidatorWeightFctType defines a validator function that returns a validated struct and/or an error.\ntype ValidatorWeightFctType func(val string) (*blkiodev.WeightDevice, error)\n\n// ValidateWeightDevice validates that the specified string has a valid device-weight format.\nfunc ValidateWeightDevice(val string) (*blkiodev.WeightDevice, 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\tweight, err := strconv.ParseUint(v, 10, 16)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid weight for device: %s\", val)\n\t}\n\tif weight > 0 && (weight < 10 || weight > 1000) {\n\t\treturn nil, fmt.Errorf(\"invalid weight for device: %s\", val)\n\t}\n\n\treturn &blkiodev.WeightDevice{\n\t\tPath:   k,\n\t\tWeight: uint16(weight),\n\t}, nil\n}","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/weightdevice.go#L1-L36","documentation":"Returned by ValidateWeightDevice (the validator behind --blkio-weight-device) when the input has no ':' separator or the device-path part is empty. Expected format: '<device-path>:<weight>'.","triggerScenarios":"'docker run --blkio-weight-device=200' (no device), '...=:200' (empty device key).","commonSituations":"User passes only a weight assuming a global default, or forgets the colon/device pair.","solutions":["Provide the full '<device-path>:<weight>' pair, e.g. '--blkio-weight-device=/dev/sda:200'.","Keep the device on the left, weight on the right.","Use multiple flags for multiple devices rather than comma-separating in one value."],"exampleFix":"# before\ndocker run --blkio-weight-device=200 ubuntu\n# after\ndocker run --blkio-weight-device=/dev/sda:200 ubuntu","handlingStrategy":"validation","validationCode":"// Require the '<device>:<weight>' shape before ValidateWeightDevice.\nimport \"strings\"\n\nfunc hasWeightShape(s string) bool {\n    k, v, ok := strings.Cut(s, \":\")\n    return ok && k != \"\" && v != \"\"\n}\n\n// if !hasWeightShape(val) { return fmt.Errorf(\"expected <device-path>:<weight>, got %q\", val) }","typeGuard":null,"tryCatchPattern":"if _, err := opts.ValidateWeightDevice(val); err != nil {\n    return err // bad format: <val>\n}","preventionTips":["Always pair a device path with a weight, separated by a colon.","Repeat the flag per device rather than comma-separating.","Put device on the left, weight on the right."],"tags":["docker","blkio","weight","cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}