{"record":{"id":"1f443a99fa707aaa","repo":"jaegertracing/jaeger","slug":"failed-to-process-bucket-w","errorCode":null,"errorMessage":"failed to process bucket: %w","messagePattern":"failed to process bucket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/metricstore/elasticsearch/to_domain.go","lineNumber":77,"sourceCode":"\t\treturn []*metrics.Metric{\n\t\t\t{\n\t\t\t\tLabels:       labels,\n\t\t\t\tMetricPoints: toDomainMetricPoints(t.bucketsToPointsFunc(buckets)),\n\t\t\t},\n\t\t}, nil\n\t}\n\n\t// Handle grouped results when groupByOp is true\n\tagg, found := result.Aggregations.Terms(aggName)\n\tif !found {\n\t\treturn nil, fmt.Errorf(\"%s aggregation not found\", aggName)\n\t}\n\n\tvar metricsData []*metrics.Metric\n\tfor _, bucket := range agg.Buckets {\n\t\tmetric, err := t.processOperationBucket(bucket, labels)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to process bucket: %w\", err)\n\t\t}\n\t\tmetricsData = append(metricsData, metric)\n\t}\n\n\treturn metricsData, nil\n}\n\nfunc buildServiceLabels(serviceNames []string) []*metrics.Label {\n\tlabels := make([]*metrics.Label, len(serviceNames))\n\tfor i, name := range serviceNames {\n\t\tlabels[i] = &metrics.Label{Name: \"service_name\", Value: name}\n\t}\n\treturn labels\n}\n\nfunc (t *Translator) processOperationBucket(bucket esclient.AggregationBucket, baseLabels []*metrics.Label) (*metrics.Metric, error) {\n\tkey := bucket.Key\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/metricstore/elasticsearch/to_domain.go#L59-L95","documentation":"While iterating buckets of the terms aggregation in grouped mode, each bucket is converted via processOperationBucket. If any individual bucket fails conversion (e.g. its nested date_histogram is missing), toDomainMetrics aborts and wraps the cause as 'failed to process bucket', naming no bucket key — the inner error does.","triggerScenarios":"toDomainMetrics with GroupByOperation=true where at least one terms bucket lacks the nested date_histogram sub-aggregation expected by processOperationBucket.","commonSituations":"Partial aggregation responses from ES (some buckets built by an older job without the sub-agg); mixed-version cluster during upgrade; manually crafted query missing the nested date_histogram.","solutions":["Inspect the wrapped cause for 'date_histogram aggregation not found in bucket <key>' to find the offending operation.","Re-run for a time range where all rollup jobs wrote complete buckets.","Ensure the query always registers the nested date_histogram sub-aggregation under dateHistAggName."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for _, b := range agg.Buckets {\n  if _, ok := b[\"date_histogram\"]; !ok {\n    log.Printf(\"bucket %v missing date_histogram, skipping\", b.Key)\n  }\n}","typeGuard":null,"tryCatchPattern":"metric, err := t.processOperationBucket(bucket, labels)\nif err != nil {\n  log.Printf(\"skipping bucket %q: %v\", bucket.Key, err)\n  continue // degrade to partial results instead of failing all\n}","preventionTips":["Ensure every ES rollup job includes the nested date_histogram sub-aggregation.","Complete cluster upgrades so all buckets share one schema.","Decide whether partial bucket data should degrade gracefully rather than abort."],"tags":["elasticsearch","metrics","aggregation","bucket-processing"],"backgroundTag":"aggregation-mapping-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}