-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Morecast: Adds instructive error message for failed forecast publishes #3973
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3973 +/- ##
==========================================
+ Coverage 79.92% 80.47% +0.55%
==========================================
Files 298 298
Lines 11430 11431 +1
Branches 541 541
==========================================
+ Hits 9135 9199 +64
- Misses 2109 2113 +4
+ Partials 186 119 -67 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -120,7 +120,7 @@ async def save_forecasts(forecasts: MoreCastForecastRequest, response: Response, | |||
clear_cache_matching(station_id) | |||
except Exception as exc: | |||
logger.error("Encountered error posting forecast data to WF1 API", exc_info=exc) | |||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Error submitting forecast(s) to WF1") | |||
raise WF1_HTTP_ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should raise WF1_HTTP_ERROR
in two places or just catch it here
except WF1_HTTP_ERROR as exc:
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to catch any exception here, not just WF1_HTTP_ERROR
. We log the original exception for our own troubleshooting but re-raise WF1_HTTP_ERROR
so they client knows it's an unrecoverable error on our end and receive the same instructions to attempt to retry.
Lots of things could fail here independently (getting auth token, pushing the forecasts, clearing from cache, etc.) but if anything fails here it's not something the client can do anything about besides retrying. We may be able to fix it, so we just log it for ourselves.
@@ -11,6 +11,14 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
WF1_FORECAST_POST_URL = f"{config.get('WFWX_BASE_URL')}/v1/dailies/daily-bulk" | |||
WF1_HTTP_ERROR = HTTPException( | |||
status_code=status.HTTP_400_BAD_REQUEST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The 400 series of codes are typically used when there is a problem with the client's request. It might be better to return a 500 or 503 indicating a server side issue.
Quality Gate passedIssues Measures |
Adds an error message that's a bit more useful to the user. Adjusts the text somewhat to the ticket to clarify their retry option.
Closes #3801
Test Links:
Landing Page
MoreCast
Percentile Calculator
C-Haines
FireBat
FireBat bookmark
Auto Spatial Advisory (ASA)
HFI Calculator