Economy routes return 500 for Israel when a policy ID of 0 means current law
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 18
- 分支
- 33
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 18
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PolicyEngine/policyengine-api 的其他 Issue
-
難度 1/5 1-3 小時 新手友好度 88/100
PolicyEngine/policyengine-api#3911 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
PolicyEngine/policyengine-api#3910 ·
維護者通常 1 天內回覆
-
Enable ruff security, logging and debugging rules (S, T20, LOG, G, DTZ, ERA, TD, FIX, EXE)可能已有人在做 @anth-volk 今天認領。 未關閉
難度 4/5 3-5 天 新手友好度 18/100
PolicyEngine/policyengine-api#3914 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 38/100
PolicyEngine/policyengine-api#3912 ·
維護者通常 1 天內回覆
-
validate_country prints "Validating country" on every request可能已有人在做 @anth-volk 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 25/100
PolicyEngine/policyengine-api#3909 ·
維護者通常 1 天內回覆
查看 PolicyEngine/policyengine-api 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
onyx-dot-app/onyx#16016 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
black --check exits 0 and prints All done when a multi file run is interrupted可能已有人在做 @jiteshgulati 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 2 天內回覆
-
Non-positive worker counts wait for results without starting workers可能已有人在做 @IlyaKhalafi 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆