{"record":{"id":"6f1327fbc1bc2ebe","repo":"tsenart/vegeta","slug":"bad-buckets-s","errorCode":null,"errorMessage":"bad buckets: %s","messagePattern":"bad buckets: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/histogram.go","lineNumber":69,"sourceCode":"\t\t}\n\t}\n\tbuf.WriteString(\"}\")\n\n\treturn buf.Bytes(), nil\n}\n\n// Nth returns the nth bucket represented as a string.\nfunc (bs Buckets) Nth(i int) (left, right string) {\n\tif i >= len(bs)-1 {\n\t\treturn bs[i].String(), \"+Inf\"\n\t}\n\treturn bs[i].String(), bs[i+1].String()\n}\n\n// UnmarshalText implements the encoding.TextUnmarshaler interface.\nfunc (bs *Buckets) UnmarshalText(value []byte) error {\n\tif len(value) < 2 || value[0] != '[' || value[len(value)-1] != ']' {\n\t\treturn fmt.Errorf(\"bad buckets: %s\", value)\n\t}\n\tfor i, v := range strings.Split(string(value[1:len(value)-1]), \",\") {\n\t\td, err := time.ParseDuration(strings.TrimSpace(v))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// add a default range of [0-Buckets[0]) if needed\n\t\tif i == 0 && d > 0 {\n\t\t\t*bs = append(*bs, 0)\n\t\t}\n\t\t*bs = append(*bs, d)\n\t}\n\tif len(*bs) == 0 {\n\t\treturn fmt.Errorf(\"bad buckets: %s\", value)\n\t}\n\treturn nil\n}\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/lib/histogram.go#L51-L87","documentation":"vegeta's Buckets type (used by -buckets for histogram reporting) implements encoding.TextUnmarshaler and requires the literal format \"[d1,d2,...]\" — starting with '[' and ending with ']' and at least two characters. Any value not shaped like a bracketed list is rejected with this error before durations are parsed.","triggerScenarios":"Calling Buckets.UnmarshalText (directly or via the -buckets flag's Set) with a value that is empty, a single character, or not wrapped in brackets — e.g. \"100ms,200ms\".","commonSituations":"Forgetting the surrounding brackets on the CLI; the shell eating the brackets (unquoted); passing a plain comma list copied from documentation prose.","solutions":["Wrap the durations in brackets: -buckets='[100ms,200ms,1s]'.","Quote the value in the shell so brackets are not glob-expanded or stripped.","Ensure the value has at least 2 characters (non-empty \"[]\").","After the format, verify each entry parses as a Go duration (100ms, 2s, 1m...)."],"exampleFix":"// before\nvegeta report -buckets=100ms,200ms results.bin\n// after\nvegeta report -buckets='[100ms,200ms]' results.bin","handlingStrategy":"validation","validationCode":"func validBuckets(s string) bool {\n\tif len(s) < 2 || s[0] != '[' || s[len(s)-1] != ']' {\n\t\treturn false\n\t}\n\tfor _, v := range strings.Split(s[1:len(s)-1], \",\") {\n\t\tif _, err := time.ParseDuration(strings.TrimSpace(v)); err != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always wrap bucket lists in brackets: '[100ms,200ms]'.","Quote the flag value in the shell to protect brackets.","Ensure each entry is a valid Go duration with a unit.","Pre-validate with the validBuckets helper in wrappers."],"tags":["cli","flag-parsing","histogram"],"backgroundTag":"bad-buckets-format","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}