Return targets in a deterministic order - #3385
Merged
Merged
Conversation
Targets are held in a `set`, so every endpoint which returns a list of them
iterated in hash order. Target IDs are random hex and `str` hashing is salted
per process, so that order varied between runs.
For the Query API this was not merely cosmetic: `max_num_results` truncates the
result list after it is built, so a query matching three targets with
`max_num_results=1` returned an arbitrary one of the three, and a different one
on the next run. `include_target_data=top` attached target data to whichever
result happened to come first.
Order the targets returned by the Query API, `GET /targets` and
`GET /duplicates/{target_id}` by upload date and then by target ID. The mock has
no match score, so it cannot reproduce real Vuforia's best-match-first order;
the differences document now says so, so that callers do not read the mock's
order as a ranking.
Closes #3369.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
adamtheturtle
temporarily deployed
to
development
August 9, 2026 17:24 — with
GitHub Actions
Inactive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Targets are held in a
set, so every endpoint which returns a list of them iterated in hash order, which varies between runs because target IDs are random hex andstrhashing is salted per process. For the Query API this was not merely cosmetic:max_num_resultstruncates the result list after it is built, so a query matching three targets withmax_num_results=1returned an arbitrary one of the three, andinclude_target_data=topattached target data to whichever result happened to come first.The Query API,
GET /targetsandGET /duplicates/{target_id}now order targets by upload date and then by target ID, on both the in-process and Flask backends. The mock has no match score, so it cannot reproduce real Vuforia's best-match-first order;differences-to-vws.rstnow says so, so that callers do not read the mock's order as a ranking.New tests cover the order for each of the three endpoints; they skip on the real backend, whose order the mock does not claim to match.
Closes #3369.
🤖 Generated with Claude Code