{"id":"0241f3137c050ee6","repo":"docker/cli","slug":"invalid-weight-for-device-s","errorCode":null,"errorMessage":"invalid weight for device: %s","messagePattern":"invalid weight for device: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/weightdevice.go","lineNumber":26,"sourceCode":"\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}\n\n// WeightdeviceOpt defines a map of WeightDevices\ntype WeightdeviceOpt struct {\n\tvalues    []*blkiodev.WeightDevice\n\tvalidator ValidatorWeightFctType\n}\n\n// NewWeightdeviceOpt creates a new WeightdeviceOpt","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/opts/weightdevice.go#L8-L44","documentation":"Error \"invalid weight for device: %s\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/weightdevice.go:26 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}