Repository navigation
Conversation
A request the economy routes refuse with 400 or 404 (a year outside the country's years, an unknown region, a policy the country does not have) must add no record at ERROR, which the telemetry error report groups. Unexpected failures, including a ValueError raised after validation, must still be logged at ERROR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The annual and budget-window economy requests logged every exception at ERROR, including the ones the routes answer with 400 or 404. The telemetry error report groups every record at ERROR or above, so each refusal formed an error group. A PolicyNotFoundError, or a ValueError raised before the request's setup options are built, is now logged at WARNING as a refusal. Any other failure, including a ValueError raised after validation, is still logged at ERROR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4220 +/- ##
==========================================
- Coverage 92.14% 92.12% -0.03%
==========================================
Files 296 297 +1
Lines 16696 16714 +18
Branches 2722 2724 +2
==========================================
+ Hits 15384 15397 +13
- Misses 795 801 +6
+ Partials 517 516 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4219
Summary
Refused economic impact request(orRefused budget-window economic impact request), and every other failure at ERROR with the existing message. Both records keeperror_type; anSPMValidationErroralso records itserror_code, such asDATASET_YEAR_UNAVAILABLE.PolicyNotFoundError, 404); orValueError(400): a year outside the country's years (Define each country's years once and refuse society-wide requests for other years #4212), an unknown region, or a dataset, breakdown or SPM setting the API does not offer. Validation ends once the request's setup options are built, before any stored result is read or any job is sent.ValueErrorraised after validation stays at ERROR, although the route also answers it with 400. Such errors report a state the API did not expect, such asUnknown impact status, or replay a typed failure the simulation service stored for the request.policyengine_api/services/economy_request_failures.pyholds the rule (is_refused_request) and the logging (log_economy_request_failure), used by bothexceptblocks. It is added toECONOMY_SERVICE_LOGGER_MODULES, so tests that replace the economy loggers replace it too.Why
The daily telemetry error report groups every record at severity ERROR or above (
severity_number >= 500in.github/scripts/telemetry_error_issues/bigquery.py). A refused request'srequest.completedrecord is INFO (outcomeclient_error), so the service's own ERROR record was the only one that put it in an error group, as amessagegroup on the economy route. #4212 now refuses UK years outside 2024 to 2032, the main source of #4099, #4216, #4217 and #4218, so those refusals would otherwise form a new error group.Limit
A
ValueErrorraised while the setup options are being built for a reason other than the request, such as a bug in building them, now logs at WARNING. The route already answers it with 400 as a client error.Testing
tests/unit/routes/test_economy_refusal_log_severity.py(new) serves both economy routes from a real service over in-memory caches, through a real observability runtime with the API's logging settings that keeps every record it writes. So it checks every record a request writes, including itsrequest.completedrecord and standard-library logging.DATASET_YEAR_UNAVAILABLEfor the year).RuntimeErrorfrom the policy lookup (500), and aValueErrorfrom it after validation (400), each still write one ERROR record with the failure message.make qualitypasses.🤖 Generated with Claude Code