{"record":{"id":"422c43e2c93a4e7a","repo":"jaegertracing/jaeger","slug":"searchdepth-must-not-be-greater-than-d","errorCode":null,"errorMessage":"SearchDepth must not be greater than %d","messagePattern":"SearchDepth must not be greater than (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/integration/trace_reader.go","lineNumber":130,"sourceCode":"\t})\n\tif err != nil {\n\t\treturn operations, err\n\t}\n\tfor _, operation := range res.Operations {\n\t\toperations = append(operations, tracestore.Operation{\n\t\t\tName:     operation.Name,\n\t\t\tSpanKind: operation.SpanKind,\n\t\t})\n\t}\n\treturn operations, nil\n}\n\n// toProtoQuery renders a search as the api_v3 request the query service reads, which is the\n// only shape the e2e tests can send: they drive jaeger over the wire rather than calling a\n// Reader, so a predicate this function drops is one no e2e test can exercise.\nfunc toProtoQuery(query tracestore.TraceQueryParams) (*api_v3.TraceQueryParameters, error) {\n\tif query.SearchDepth > math.MaxInt32 {\n\t\treturn nil, fmt.Errorf(\"SearchDepth must not be greater than %d\", math.MaxInt32)\n\t}\n\tprotoQuery := &api_v3.TraceQueryParameters{\n\t\tServiceName:   query.ServiceName,\n\t\tOperationName: query.OperationName,\n\t\tAttributes:    jptrace.PcommonMapToPlainMap(query.Attributes),\n\t\tStartTimeMin:  query.StartTimeMin,\n\t\tStartTimeMax:  query.StartTimeMax,\n\t\tDurationMin:   query.DurationMin,\n\t\tDurationMax:   query.DurationMax,\n\t\tSearchDepth:   int32(query.SearchDepth), //nolint:gosec // G115 - bounds checked above\n\t}\n\tif query.Filter != nil {\n\t\tfilter, err := expressionproto.ToProto(query.Filter)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot encode the query filter: %w\", err)\n\t\t}\n\t\tprotoQuery.Filter = filter\n\t}","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/integration/trace_reader.go#L112-L148","documentation":"toProtoQuery converts tracestore.TraceQueryParams to the api_v3 protobuf TraceQueryParameters, whose SearchDepth field is int32. If the caller's SearchDepth exceeds math.MaxInt32 the conversion would silently truncate, so the function rejects it with 'SearchDepth must not be greater than 2147483647'.","triggerScenarios":"Calling search through the api_v3 traceReader with a TraceQueryParams whose SearchDepth is set to a value greater than math.MaxInt32 (practically only an unset/default sentinel like math.MaxUint64 or a huge default).","commonSituations":"Passing a default SearchDepth sentinel (e.g. math.MaxUint64 used by tracestore to mean 'no limit') directly into the api_v3 reader without clamping it first.","solutions":["Clamp or unset SearchDepth before calling search: use a sane value (e.g. 100) or leave zero when you don't need depth limiting","Set an explicit bounded SearchDepth in the TraceQueryParams your tests/config construct","If this comes from a shared default constant, convert the sentinel to MaxInt32 before invoking the api_v3 reader"],"exampleFix":"// before\nquery := tracestore.TraceQueryParams{SearchDepth: math.MaxUint64}\n// after\nif query.SearchDepth > math.MaxInt32 {\n    query.SearchDepth = math.MaxInt32\n}","handlingStrategy":"validation","validationCode":"if query.SearchDepth > math.MaxInt32 {\n    query.SearchDepth = math.MaxInt32 // clamp sentinel/default values\n}","typeGuard":null,"tryCatchPattern":"q, err := toProtoQuery(params)\nif err != nil {\n    if strings.Contains(err.Error(), \"SearchDepth must not\") {\n        params.SearchDepth = 100\n        q, err = toProtoQuery(params)\n    }\n    if err != nil { return err }\n}","preventionTips":["Clamp default/sentinel SearchDepth values (e.g. MaxUint64) before remote queries","Always set explicit bounded SearchDepth in test helpers","Centralize TraceQueryParams construction so bounds are checked once"],"tags":["validation","integer-overflow","api-v3"],"backgroundTag":"integer-overflow-validation","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}