Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (h *searchTracesHandler) buildQuery(input types.SearchTracesInput) (querysv
if searchDepth <= 0 {
searchDepth = defaultSearchDepth
}
if searchDepth > h.maxResults {
if h.maxResults > 0 && searchDepth > h.maxResults {
searchDepth = h.maxResults
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,28 @@ func TestSearchTracesHandler_Handle_LimitEnforced(t *testing.T) {
// Returned traces are capped at exactly the limit (5 traces, limit=3 → exactly 3 traces)
assert.Len(t, output.Traces, 3)
}

func TestSearchTracesHandler_Handle_SearchDepthNotClampedWhenUnlimited(t *testing.T) {
testTrace := createTestTrace("trace001", "svc", "/a", false)

mock := &mockQueryService{
findTracesFunc: func(_ context.Context, query querysvc.TraceQueryParams) iter.Seq2[[]ptrace.Traces, error] {
// When maxResults=0 (unlimited), searchDepth must not be clamped to 0
assert.Equal(t, 50, query.SearchDepth)
return func(yield func([]ptrace.Traces, error) bool) {
Comment on lines +522 to +524
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test assumes maxResults=0 is a supported “unlimited” configuration, but the Jaeger MCP config currently validates max_search_results as range(1|1000) (so 0 would be rejected). Consider either (a) updating the config validation/docs to explicitly allow 0 for unlimited, or (b) adding a brief note here explaining why 0 is still a meaningful/possible value for searchTracesHandler.maxResults (e.g., internal usage) to avoid confusion for future maintainers.

Copilot uses AI. Check for mistakes.
yield([]ptrace.Traces{testTrace}, nil)
}
},
}

handler := &searchTracesHandler{queryService: mock, maxResults: 0}

input := types.SearchTracesInput{
StartTimeMin: "-1h",
ServiceName: "svc",
SearchDepth: 50,
}

_, _, err := handler.handle(context.Background(), &mcp.CallToolRequest{}, input)
require.NoError(t, err)
}
Loading