Skip to content

fix: skip update prompt when PyPI check fails (#480) - #486

Merged
kaifcodec merged 1 commit into
kaifcodec:mainfrom
A-S-Manoj:fix-false-update-prompt-480
Aug 1, 2026
Merged

fix: skip update prompt when PyPI check fails (#480)#486
kaifcodec merged 1 commit into
kaifcodec:mainfrom
A-S-Manoj:fix-false-update-prompt-480

Conversation

@A-S-Manoj

Copy link
Copy Markdown
Contributor

Fixes #480

Problem

get_pypi_version() catches any request failure (offline, PyPI down, rate limited, etc.) and returns None instead of raising. check_for_updates() compared this directly against the local version with no None check, so current_ver != None was always true on any failed check, producing a false prompt:

[!] New version available: 1.4.1.9 -> None
Do you want to update? (y/n/d: don't ask again):

This isn't a rare edge case, it fires on any network failure. It also feeds into update_self(), which uninstalls before reinstalling, so accepting the prompt while genuinely offline risks leaving the tool uninstalled.

Fix

Added a check for latest_ver is None immediately after it's fetched, and return early with a clear message instead of comparing it against current_ver:

  • Could not reach PyPI → print "[!] Could not reach PyPI, skipping update check." and return, no prompt shown
  • Real version mismatch → unchanged, still prompts as before
  • Versions match → unchanged, stays silent

Changes

  • user_scanner/utils/updater_logic.py — added the None check in check_for_updates() before the version comparison
  • tests/test_updater_logic.py (new) — regression coverage for the three cases above

Testing

Ran the full test suite against current main (151 passed). Verified the new tests fail on the unmodified code and pass with the fix:

  • PyPI unreachable → no prompt shown, input() never called
  • Real update available → prompt still shown
  • Versions match → no prompt, input() never called

Without the fix, the unreachable case doesn't just show a false prompt, it goes on to crash with 'NoneType' object has no attribute 'strip' once input() is unexpectedly reached, since the mocked/aborted input path returns None instead of a string.

No existing test covered this path. The closest one, test_pypi_error_is_caught in the incoming test_updater_logic.py PR, mocks get_pypi_version to raise rather than return None, so it doesn't exercise this bug.

@kaifcodec kaifcodec left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@A-S-Manoj LGTM.
Thank you for the tests.

@kaifcodec
kaifcodec merged commit 8580f6b into kaifcodec:main Aug 1, 2026
2 checks passed
@kaifcodec kaifcodec added enhancement New feature, request, code improvements/upgrade, performance boost bug fix Fixed a bug in existing files labels Aug 1, 2026
@A-S-Manoj
A-S-Manoj deleted the fix-false-update-prompt-480 branch August 1, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Fixed a bug in existing files enhancement New feature, request, code improvements/upgrade, performance boost

2 participants