Skip to content

[Bug] Failed PyPI version check is shown as a false "new version available" prompt #480

Description

@A-S-Manoj

Summary

When the PyPI version check fails (offline, PyPI down, rate limited, etc.), the tool incorrectly reports that a new version is available.

Where

user_scanner/utils/updater_logic.py, check_for_updates()

Details

get_pypi_version() catches any request failure and returns None:

def get_pypi_version(pypi_url):
    try:
        pypi_version = httpx.get(pypi_url, timeout=7).json()["info"]["version"]
    except Exception as e:
        print(e)
        return None
    return pypi_version

check_for_updates() compares this directly without checking for None:

if current_ver != latest_ver:
    print(f"\n[!] New version available: {R}{current_ver}{X} -> {C}{latest_ver}{X}\n")
    choice = input("Do you want to update? (y/n/d): ")

Since current_ver is always a real string, this is True on every failed check, producing:

[!] New version available: 1.4.1.9 -> None

Reproduced by mocking get_pypi_version to return None and calling check_for_updates() directly.

Impact

Fires on any network failure, not an edge case. Also feeds into update_self(), which uninstalls before reinstalling, so accepting the prompt while offline risks leaving the tool uninstalled.

Suggested fix

Skip the prompt when latest_ver is None.

I'd like to work on this myself.

Metadata

Metadata

Assignees

Labels

bug fixFixed a bug in existing files

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions