Skip to content

Fix PyPI latest-date handling when upload_time_iso_8601 is missing#864

Open
drawliin wants to merge 1 commit intoaboutcode-org:mainfrom
drawliin:fix/pypi-missing-upload-time-latest-date
Open

Fix PyPI latest-date handling when upload_time_iso_8601 is missing#864
drawliin wants to merge 1 commit intoaboutcode-org:mainfrom
drawliin:fix/pypi-missing-upload-time-latest-date

Conversation

@drawliin
Copy link
Copy Markdown

@drawliin drawliin commented Apr 4, 2026

Closes: #863

Summary

Fix PypiVersionAPI.get_latest_date() so PyPI release entries without
upload_time_iso_8601 are skipped instead of causing an UnboundLocalError.

Changes

  • skip invalid download entries that do not include upload_time_iso_8601
  • keep returning the latest valid parsed timestamp
  • return None when no valid timestamps are available
  • add regression tests for mixed valid/invalid entries
  • add regression tests for the all-invalid case

Why

The previous implementation could reference current_date before assignment
when a PyPI download entry was missing upload_time_iso_8601.

Testing

I added coverage in packagedb/tests/test_package_managers.py for:

  • entries with missing timestamps followed by valid ones
  • entries with no valid timestamps

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.

PypiVersionAPI.get_latest_date() crashes when a release entry is missing upload_time_iso_8601

1 participant