Summary
In go/internal/database/datastore/affected_versions.go, computeAffectedVersions calls osvutil.SortEvents and discards the error:
_ = osvutil.SortEvents(eHelper, events)
When any event version fails Parse/Compare, SortEvents re-sorts lexicographically (documented as arbitrary/stable) and returns that error to signal the order is not semantic. The caller still derives coarse_min / coarse_max from positional assumptions that only hold under a semantic sort (first introduced, last event).
Those coarse bounds become hard Datastore inequality filters in buildVersionMatcher, so a row excluded by a wrongly-narrowed window is never returned to the semantic matcher.
Worked example (Packagist)
Events: introduced 1.0, fixed 9.0, introduced 20.0, fixed 30.0, introduced 1.0#bad (Packagist rejects #).
Lexicographic fallback order ends with fixed 9.0, so today's code emits coarse_max = coarse(9.0). Version 25.0 is semantically in-range (20.0–30.0) but fails the coarse_max >= coarse(25.0) pre-filter.
Expected
On SortEvents error, leave coarse_min/coarse_max at the unbounded defaults (00:000… / 99:999…), matching the Python _get_coarse_min_max ValueError path that resets to MIN/MAX.
Note
This is a correctness / false-negative matching bug in the Go datastore index path (live importer/worker), not a security advisory request. Happy to send a small patch + unit test once this is assigned per CONTRIBUTING.
Summary
In
go/internal/database/datastore/affected_versions.go,computeAffectedVersionscallsosvutil.SortEventsand discards the error:When any event version fails
Parse/Compare,SortEventsre-sorts lexicographically (documented as arbitrary/stable) and returns that error to signal the order is not semantic. The caller still derivescoarse_min/coarse_maxfrom positional assumptions that only hold under a semantic sort (firstintroduced, last event).Those coarse bounds become hard Datastore inequality filters in
buildVersionMatcher, so a row excluded by a wrongly-narrowed window is never returned to the semantic matcher.Worked example (Packagist)
Events:
introduced 1.0,fixed 9.0,introduced 20.0,fixed 30.0,introduced 1.0#bad(Packagist rejects#).Lexicographic fallback order ends with
fixed 9.0, so today's code emitscoarse_max = coarse(9.0). Version25.0is semantically in-range (20.0–30.0) but fails thecoarse_max >= coarse(25.0)pre-filter.Expected
On
SortEventserror, leavecoarse_min/coarse_maxat the unbounded defaults (00:000…/99:999…), matching the Python_get_coarse_min_maxValueErrorpath that resets toMIN/MAX.Note
This is a correctness / false-negative matching bug in the Go datastore index path (live importer/worker), not a security advisory request. Happy to send a small patch + unit test once this is assigned per CONTRIBUTING.