{"record":{"id":"a9bd5430165274d2","repo":"jaegertracing/jaeger","slug":"could-not-find-aggregation-of","errorCode":null,"errorMessage":"could not find aggregation of ","messagePattern":"could not find aggregation of ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/elasticsearch/tracestore/core/service_operation.go","lineNumber":188,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"search operations failed: %w\", err)\n\t}\n\treturn aggregationKeys(resp, operationsAggregation)\n}\n\n// aggregationKeys extracts the bucket keys of a named terms aggregation. A\n// response with no aggregations yields an empty slice; a response missing the\n// requested aggregation is an error.\nfunc aggregationKeys(resp *esclient.SearchResponse, name string) ([]string, error) {\n\tif resp == nil {\n\t\treturn nil, errors.New(\"nil search response\")\n\t}\n\tif resp.Aggregations == nil {\n\t\treturn []string{}, nil\n\t}\n\tagg, ok := resp.Aggregations.Terms(name)\n\tif !ok {\n\t\treturn nil, errors.New(\"could not find aggregation of \" + name)\n\t}\n\tkeys := make([]string, 0, len(agg.Buckets))\n\tfor _, bucket := range agg.Buckets {\n\t\tkeys = append(keys, bucket.Key)\n\t}\n\treturn keys, nil\n}\n\nfunc hashCode(s dbmodel.Service) string {\n\th := fnv.New64a()\n\th.Write([]byte(s.ServiceName))\n\th.Write([]byte(s.OperationName))\n\treturn strconv.FormatUint(h.Sum64(), 16)\n}\n","sourceCodeStart":170,"sourceCodeEnd":203,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/elasticsearch/tracestore/core/service_operation.go#L170-L203","documentation":"This error is raised by aggregationKeys when the search response has an Aggregations section but does not contain the requested terms aggregation (resp.Aggregations.Terms(name) returns !ok). The message is dynamic: \"could not find aggregation of \" + name. The caller cannot extract bucket keys without the expected aggregation.","triggerScenarios":"getServices or getOperations requesting a named terms aggregation (e.g. \"services\" or \"operations\") that is absent from the ES response — typically because the query sent to Elasticsearch did not include that aggregation, or the response was produced by a differently shaped query.","commonSituations":"Version skew where the aggregation name or query structure changed; a proxy rewriting the search body; misconfigured requests that silently drop aggregations (e.g. size/termination settings); testing against a hand-built response missing the aggregation.","solutions":["Verify the request sent to ES actually includes the named terms aggregation matching the name passed to aggregationKeys.","Check Elasticsearch/OpenSearch version compatibility and that the response includes aggregations.","Inspect intermediate proxies/plugins that could strip or rename aggregations in responses.","Update the Jaeger storage layer if using an older/newer IDL or client with changed aggregation names."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if resp != nil && resp.Aggregations != nil {\n    if _, ok := resp.Aggregations.Terms(\"services\"); !ok {\n        return fmt.Errorf(\"missing services aggregation in response\")\n    }\n}","typeGuard":"func hasTermsAgg(r *esclient.SearchResponse, name string) bool {\n    return r != nil && r.Aggregations != nil && func() bool { _, ok := r.Aggregations.Terms(name); return ok }()\n}","tryCatchPattern":"keys, err := aggregationKeys(resp, aggName)\nif err != nil && strings.HasPrefix(err.Error(), \"could not find aggregation of \") {\n    // missing aggregation: log full response for diagnosis\n    log.Printf(\"aggregation %q missing in ES response\", aggName)\n}","preventionTips":["Keep aggregation names in shared constants so query and parser never drift apart.","Verify ES/OpenSearch versions against the Jaeger support matrix after upgrades.","Log raw responses when aggregation parsing fails to spot proxies stripping fields."],"tags":["elasticsearch","aggregation","response-parsing"],"backgroundTag":"missing-aggregation-in-response","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}