Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Economy routes return 500 for Israel when a policy ID of 0 means current law

Đang mở
#3,908 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, backend

Hướng nghiên cứu

Start in policyengine_api/utils/get_current_law.py, where the lookup covers only uk, us, ca and ng, then check how policyengine_api/routes/economy_routes.py calls it for the single-year and budget-window routes. The COUNTRIES list in policyengine_api/constants.py includes il, so that is the case to reproduce. Done means Israel with policy ID 0 either resolves to a stored current-law ID or returns a clear 4xx, with no 500. Confirm first whether Israel has a stored current-law policy, since that choice decides the fix.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The single-year and budget-window economy routes (/<country_id>/economy/<policy_id>/over/<baseline_policy_id> and its budget-window variant in policyengine_api/routes/economy_routes.py) treat a policy ID of 0 as "current law" and resolve it with get_current_law_policy_id(country_id).

get_current_law_policy_id (policyengine_api/utils/get_current_law.py) only knows uk, us, ca and ng, but COUNTRIES in policyengine_api/constants.py also includes il, so validate_country lets Israel through. For country_id="il" with either ID set to 0, the dictionary lookup raises KeyError, which the generic error handler turns into a 500.

Expected

Either Israel resolves to its current-law policy ID, or the route returns a clear 4xx saying current law is not available for Israel.

Notes

  • Found while documenting the code for the ruff docstring rules; behaviour was left unchanged there.
  • Worth checking whether Israel has a stored current-law policy at all before choosing between the two fixes.
Ngôn ngữ chính
Python
Star
18
Fork
33
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
18

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PolicyEngine/policyengine-api

Tất cả issue của PolicyEngine/policyengine-api

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.