Skip to content

fix(apiv3): Sort dependency links for deterministic ordering - #9127

Open
lopster568 wants to merge 1 commit into
jaegertracing:mainfrom
lopster568:fix/apiv3-dependency-sort
Open

fix(apiv3): Sort dependency links for deterministic ordering#9127
lopster568 wants to merge 1 commit into
jaegertracing:mainfrom
lopster568:fix/apiv3-dependency-sort

Conversation

@lopster568

Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

Description of the changes

apiv3.Handler.GetDependencies returned links in the order the storage layer produced them, which is built from a map and therefore not stable across queries. This sorts them by parent then child before building the response, so repeated queries return the same order. Same approach as the HTTP handler (#9119) and the MCP tool (#8403).

How was this change tested?

  • New TestGetDependenciesSortsLinks: feeds the mock reader unsorted links and asserts the response is sorted. Fails on main, passes with the change.
  • make fmt, make lint (0 issues), make test (4073 tests, 0 failures) all pass. GetDependencies is at 100% coverage.

Checklist

AI Usage in this PR (choose one)

See AI Usage Policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

GetDependencies returned links in the order the storage layer produced
them, which is built from a map and therefore not stable across queries.
Sort by parent then child so the response order is deterministic.

Signed-off-by: Roshan Singh <rosh.s568@gmail.com>
@lopster568
lopster568 requested a review from a team as a code owner July 27, 2026 19:34
Copilot AI review requested due to automatic review settings July 27, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes nondeterministic ordering in the api_v3 gRPC GetDependencies response by sorting dependency links before returning them, ensuring repeated identical queries produce a stable link order (aligning behavior with the HTTP handler and the MCP tool).

Changes:

  • Sort dependency links by parent then child in apiv3.Handler.GetDependencies to make response ordering deterministic.
  • Add a unit test that feeds unsorted dependency links via a mock reader and asserts the returned order is sorted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/grpc_handler.go Sorts dependency links (parent, then child) before building the api_v3 response to ensure deterministic ordering.
cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/grpc_handler_test.go Adds a regression test asserting GetDependencies returns links in sorted order even when storage returns an unsorted slice.

@github-actions

Copy link
Copy Markdown

CI Summary Report

Metrics Comparison

⚠️ 1 metric change(s) detected (informational)

View changed metrics

For label-level diff details, open the CI run and expand the "Compare metrics and generate summary" step logs.

metrics_snapshot_badger_e2e⬇️ download diff
1 added

  • otelcol_exporter_send_failed_spans

Code Coverage

✅ Coverage 98% (baseline 98%)

➡️ View CI run | View publish logs
2026-07-27 20:03:49 UTC

@yurishkuro

Copy link
Copy Markdown
Member

@lopster568 why does the sorting need to be done in the transport later (grpc handler)? Query Service is the business layer, the data should not look different depending on whether you hit HTTP or GRPC endpoints.

@github-actions github-actions Bot added the waiting-for-author PR is waiting for author to respond to maintainer's comments label Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:bugfix-or-minor-feature waiting-for-author PR is waiting for author to respond to maintainer's comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: api_v3 GetDependencies returns dependency links in nondeterministic order

3 participants