{"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/e9452d6e785f6e365712b9d71bd7517591773c86/opts/weightdevice.go#L1-L36","documentation":"Error \"bad format: %s\" thrown in docker/cli.","triggerScenarios":"Thrown at opts/weightdevice.go:18 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}