PypiVersionAPI.get_latest_date() crashes when a PyPI release entry is missing upload_time_iso_8601
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Trong packagedb/package_managers.py, hãy kiểm tra PypiVersionAPI.get_latest_date() và cách nó xử lý từng mục tải xuống. Sử dụng các ví dụ được cung cấp để kiểm tra các mục có và không có upload_time_iso_8601, sau đó xác minh rằng các dấu thời gian hợp lệ vẫn được so sánh. Được xem là hoàn tất khi các dấu thời gian bị thiếu hoặc không thể sử dụng bị bỏ qua, ngày hợp lệ mới nhất được trả về và None được trả về khi không tồn tại dấu thời gian nào có thể sử dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
While reviewing packagedb/package_managers.py, I noticed a bug in PypiVersionAPI.get_latest_date().
The function currently assumes that every download entry in a PyPI release contains upload_time_iso_8601. If one of the entries is missing that field, current_date is never assigned, but it is still used later in the loop. That can raise an UnboundLocalError instead of simply skipping the invalid entry.
Current code:
latest_date = None
for download in downloads:
upload_time = download.get("upload_time_iso_8601")
if upload_time:
current_date = dateparser.parse(upload_time)
if not latest_date:
latest_date = current_date
else:
if current_date > latest_date:
latest_date = current_date
return latest_date
A minimal example that can trigger this is:
downloads = [
{},
{"upload_time_iso_8601": "2010-12-23T05:14:23.509436Z"},
]
In this case, the function should ignore the first item and return the parsed date from the second one, but it can fail on the first item because current_date is undefined.
Expected behavior:
skip entries that do not have upload_time_iso_8601
continue processing the remaining valid entries
return the latest valid date
return None if none of the entries contain a usable timestamp
A simple fix would be to initialize current_date = None inside the loop and continue when upload_time_iso_8601 is missing.
Reference:
PyPI JSON API documentation
- Ngôn ngữ chính
- HTML
- Star
- 70
- Fork
- 74
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aboutcode-org/purldb
-
purlcli failsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
aboutcode-org/purldb#891 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Incorrect set comparison between package names and PURLs in NPM sync logicCó thể đã có người làm @MuhammadBilal64 đã nhận 27 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
aboutcode-org/purldb#890 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
PypiVersionAPI.get_latest_date() crashes when a release entry is missing upload_time_iso_8601Có thể đã có người làm @drawliin đã nhận 210 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aboutcode-org/purldb#863 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add doctest and tests for clearcode coordinate helpersCó thể đã có người làm @drawliin đã nhận 218 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aboutcode-org/purldb#861 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Preserve version ordering in packagedb VersionResponseCó thể đã có người làm @drawliin đã nhận 219 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
aboutcode-org/purldb#857 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aboutcode-org/purldb
Issue tương tự
-
Published SDL drops input-field default values: a non-null field with a default renders as requiredĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
use-agent-os/agent-os#3739 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PolicyEngine/policyengine-uk#2784 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ampache/ampache#4560 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày