fix(dev-admin): a version check that did not happen says so - #127
Closed
MichaelC8E wants to merge 1 commit into
Closed
MichaelC8E wants to merge 1 commit into
MichaelC8E wants to merge 1 commit into
Conversation
The endpoint answered HTTP 200 with latest == current whenever the call to
PyPI failed, and the toolbar renders that as a green "Latest: vX — You are up
to date!". A developer several releases behind, on a machine with no route
out, was told the opposite of the truth.
The toolbar already had the right message for this — "Could not check for
updates (offline?)" on fetch's .catch — and could never reach it, because the
server turned the failure into a success.
latest is now None when the check could not be made, with a short error beside
it, and the toolbar reads that before it compares versions. Reaching PyPI and
getting a body with no version in it goes down the same path: it is the same
lie by another route.
The old test called PyPI for real and asserted latest was always a string,
which is the bug written down as an expectation. It is now stubbed, and joined
by the offline case, the unreadable-answer case, and one that holds the client
to branching on the null before the up-to-date comparison.
Verified end to end: a project pinned to 3.13.125 answers latest 3.13.131 with
the network up, and {"latest": null, "error": ...} with the registry
unreachable. It used to answer 3.13.125 both times.
Contributor
Author
|
Closing this for now — not because of anything in the diff.
The branch stays where it is; nothing here changes. |
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.
The problem
The dev-admin version check answers
200 OKwithlatest == currentwhen it never reached thepackage registry at all. The toolbar reads that as a match and renders a green
"Latest: vX — You are up to date!".
So a developer several releases behind, on a machine with no route out, is told the opposite of
the truth. The handler initialises
latest = current, wraps the registry call in a catch-all,and returns the placeholder on any failure — offline, DNS failure, timeout, a non-2xx, or an
answer it could not read a version out of.
The client is already correct and unreachable: the toolbar's
.catchwritesCould not check for updates (offline?), and it can never fire, because the server turned thefailure into a success.
The fix
latestisnullwhen the check could not be made, and anerrorstring says why. The toolbarbranches on the null before comparing versions, so a failed check reads as a failed check.
Reaching the registry and failing to read a version out of the answer takes the same path — it
is the same claim by another route.
Reproducing it
Pin the framework behind the latest release, then ask
/__dev/api/version-checktwice — oncewith the network up, once with it unreachable. The two answers should differ.
Before:
After:
Tests
Three new tests in
tests/test_dev_admin.py, and one replaced: the existingtest_version_check_handlercalled PyPI for real and assertedlatestwas always a string —the defect written down as an expectation. It now stubs
urllib.request.urlopen.Full suite on this branch: 5229 passed, with the same 14 failures the untouched base has (live
services not running locally). Each piece of the fix was reverted on its own to confirm it turns
a test red by itself.