{"record":{"id":"2f948216b1021fcb","repo":"jaegertracing/jaeger","slug":"field-s-bucket-s-could-not-be-parsed-as-dur","errorCode":null,"errorMessage":"Field [%s]: Bucket [%s] could not be parsed as duration in 'buckets' string [%s]","messagePattern":"Field \\[(.+?)\\]: Bucket \\[(.+?)\\] could not be parsed as duration in 'buckets' string \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/metrics/metrics.go","lineNumber":76,"sourceCode":"\t\t\tfor tagPair := range strings.SplitSeq(tagString, \",\") {\n\t\t\t\ttag := strings.Split(tagPair, \"=\")\n\t\t\t\tif len(tag) != 2 {\n\t\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\t\"Field [%s]: Tag [%s] is not of the form key=value in 'tags' string [%s]\",\n\t\t\t\t\t\tfield.Name, tagPair, tagString,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\ttags[tag[0]] = tag[1]\n\t\t\t}\n\t\t}\n\t\tif bucketString := field.Tag.Get(\"buckets\"); bucketString != \"\" {\n\t\t\tswitch {\n\t\t\tcase field.Type.AssignableTo(timerPtrType):\n\t\t\t\tbucketValues := strings.Split(bucketString, \",\")\n\t\t\t\tfor _, bucket := range bucketValues {\n\t\t\t\t\td, err := time.ParseDuration(bucket)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\t\t\"Field [%s]: Bucket [%s] could not be parsed as duration in 'buckets' string [%s]\",\n\t\t\t\t\t\t\tfield.Name, bucket, bucketString,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\ttimerBuckets = append(timerBuckets, d)\n\t\t\t\t}\n\t\t\tcase field.Type.AssignableTo(histogramPtrType):\n\t\t\t\tbucketValues := strings.Split(bucketString, \",\")\n\t\t\t\tfor _, bucket := range bucketValues {\n\t\t\t\t\tb, err := strconv.ParseFloat(bucket, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\t\t\"Field [%s]: Bucket [%s] could not be converted to float64 in 'buckets' string [%s]\",\n\t\t\t\t\t\t\tfield.Name, bucket, bucketString,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\thistogramBuckets = append(histogramBuckets, b)\n\t\t\t\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/metrics/metrics.go#L58-L94","documentation":"metrics.Init() parses the `buckets` tag for *Timer fields by splitting on commas and calling time.ParseDuration on each entry. Any bucket entry that is not a valid Go duration (e.g. '100' without a unit) causes this error naming the field, the bucket, and the whole buckets string.","triggerScenarios":"A *Timer field with `buckets:\"...\"` containing an entry time.ParseDuration cannot parse, such as `buckets:\"1ms,50,1s\"` or `buckets:\"10ms,\"` (empty segment).","commonSituations":"Writing bare numbers for timer buckets forgetting duration units (ms, s); typos like '1ms ' with trailing space; trailing commas from copy-paste.","solutions":["Add a duration unit to the offending bucket (e.g. '50' -> '50ms')","Remove empty segments and stray commas from the buckets string","Use valid Go duration syntax: 1ms, 100ms, 1s, 2m","Validate the whole string with time.ParseDuration on each comma-separated part before running"],"exampleFix":"// before\nDuration *Timer `metric:\"dur\" buckets:\"1,10,100\"`\n// after\nDuration *Timer `metric:\"dur\" buckets:\"1ms,10ms,100ms\"`","handlingStrategy":"validation","validationCode":"func checkTimerBuckets(s string) error {\n    for _, b := range strings.Split(s, \",\") {\n        if _, err := time.ParseDuration(b); err != nil {\n            return fmt.Errorf(\"bad duration bucket %q\", b)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := metrics.Init(&m); err != nil {\n    if strings.Contains(err.Error(), \"could not be parsed as duration\") {\n        // fix the buckets string on the named field\n    }\n    return err\n}","preventionTips":["Always include duration units (ms, s) in timer bucket values","Use Go duration literals identical to time.ParseDuration syntax","Avoid trailing commas in the buckets tag","Extract bucket lists into named constants reviewed once"],"tags":["reflection","struct-tags","metrics","duration-parsing"],"backgroundTag":"invalid-bucket-spec","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}