Skip to content

fix: sort solver candidates by parsed merged_at, not raw ISO string#882

Closed
since-2017-hub wants to merge 1 commit into
entrius:testfrom
since-2017-hub:fix/solver-sort-mixed-precision-merged-at
Closed

fix: sort solver candidates by parsed merged_at, not raw ISO string#882
since-2017-hub wants to merge 1 commit into
entrius:testfrom
since-2017-hub:fix/solver-sort-mixed-precision-merged-at

Conversation

@since-2017-hub

Copy link
Copy Markdown
Contributor

Closes: #881

Summary

find_solver_from_cross_references decides which merged PR is credited
as an issue's solver by sorting candidates by merged_at ascending,
with pr.number as a deterministic tiebreaker. The sort key was the
raw ISO 8601 string returned by GraphQL:

merged.sort(key=lambda p: (p.get('merged_at') or '', p.get('number') or 0))

… ISO precision

find_solver_from_cross_references sorted candidate closing PRs by raw
ISO 8601 strings, which only sorts correctly when every value uses the
same precision and timezone suffix. GitHub's GraphQL has historically
returned both '...:00Z' and '...:00.000Z' shapes; lexicographically
'.000Z' < 'Z', so a sub-second-precision PR sorts earlier than a
second-precision one at the same instant and steals solver
attribution from the deterministic pr.number tiebreaker.

Parse merged_at via parse_github_iso_to_utc (already imported) before
sorting, with datetime.min(UTC) as a defensive fallback for missing
values.
@anderdc

anderdc commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

GraphQL mergedAt on the timeline path find_solver_from_cross_references uses returns second-precision Z consistently — verified against #758, react/react#28000, anthropics/claude-code#1, and kubernetes/kubernetes#100000 (timeline → PR#1000). The mixed-precision trigger #881 describes isn't observable on the API path this code reads, and the issue cites no real reproduction. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] find_solver_from_cross_references sorts merged PRs by ISO string instead of parsed datetime

2 participants