Stop logging refused economy requests at ERROR

未关闭
#4,219 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@anth-volk 已经在做这个了。

开始于 2026年11月6日。

  • #4220 来自 @anth-volk —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python

调研方向

Read policyengine_api/services/economy_service.py and policyengine_api/services/economy_budget_window_submission.py, then check how the routes distinguish refused requests from other failures. The expected behavior is to log refused requests at WARNING with a refusal message while keeping other failures at ERROR; inspect the telemetry grouping behavior described in the issue to confirm completion.

由索引模型根据 Issue 内容生成。

描述

The economy service logs every request it refuses at ERROR, so refused requests form error groups in the daily telemetry error report.

What happens

EconomyService.get_economic_impact (policyengine_api/services/economy_service.py) and get_budget_window_economic_impact (policyengine_api/services/economy_budget_window_submission.py) each wrap their work in except Exception, log "Error getting economic impact" (or "Error getting budget-window economic impact") at ERROR with the exception's type, and re-raise.

That block also runs for requests the routes answer with a client error:

  • 400 for a time_period or budget-window start_year outside the country's years (SPMValidationError with DATASET_YEAR_UNAVAILABLE, added by #4212);
  • 400 for any other ValueError from request validation, such as an unknown UK region;
  • 404 for a policy the country does not have (PolicyNotFoundError).

The telemetry error report reads every record at severity ERROR or above (severity_number >= 500 in .github/scripts/telemetry_error_issues/bigquery.py). A refused request's completion record is INFO (outcome client_error), so the service's own ERROR record is the only record that puts it in an error group, as a message group on the economy route. #4212 now refuses UK economy years outside 2024 to 2032, the main source of #4099, #4216, #4217 and #4218, so each of those refusals would form a new error group.

Expected

A refused request is logged at WARNING, under a message that says it was refused, and adds no record at ERROR. Any other failure is still logged at ERROR, including a ValueError raised after the request passed validation, which the route also answers with 400.

主要语言
Python
星标
18
派生
33
平均合并
2 天 15 小时
30 天内合并 PR
110

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PolicyEngine/policyengine-api 的其他 Issue

查看 PolicyEngine/policyengine-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。