Skip to content
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

Merged
merged 4 commits into from
Oct 1, 2024

Conversation

conbrad
Copy link
Collaborator

@conbrad conbrad commented Sep 26, 2024

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

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.47%. Comparing base (5467101) to head (7a6ce0e).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@brettedw brettedw left a 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
Copy link
Collaborator

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:...

Copy link
Collaborator Author

@conbrad conbrad Oct 1, 2024

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,
Copy link
Collaborator

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.

Copy link

sonarcloud bot commented Oct 1, 2024

@conbrad conbrad merged commit 2873115 into main Oct 1, 2024
22 of 23 checks passed
@conbrad conbrad deleted the task/wf1-error-instructive-message branch October 1, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Morecast: Better Error Messages re: WF1 Failure
3 participants