fix: error handling for blog article retrieval and improve retry error logging#16118
fix: error handling for blog article retrieval and improve retry error logging#16118
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16118 +/- ##
==========================================
+ Coverage 48.09% 48.11% +0.01%
==========================================
Files 37 37
Lines 5842 5848 +6
==========================================
+ Hits 2810 2814 +4
- Misses 3032 3034 +2
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves resilience and observability around blog article retrieval by handling upstream request failures more gracefully and by reducing Sentry noise from repeated retry-related exceptions.
Changes:
- Add request exception handling around blog article retrieval and return a 502 on upstream failures.
- Extend Sentry
before_sendsampling to drop most retry errors originating from the blog/WordPress API. - Update inline comments in Sentry filtering logic to reflect the expanded scope (security + blog).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| webapp/views.py | Wrap blog article retrieval in a try/except and respond with 502 for upstream request failures. |
| webapp/app.py | Add Sentry sampling logic for retry errors coming from admin.insights.ubuntu.com. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| Timeout, | ||
| HTTPError, | ||
| ): | ||
| return flask.make_response(flask.render_template("500.html"), 502) |
There was a problem hiding this comment.
The code indicates it's a server downtimeand not a server code error
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
BlogRedirects.dispatch_request has no error handling around the WordPress API call
(admin.insights.ubuntu.com). When the API returns repeated 503s, the
ConnectionError propagates unhandled — resulting in noisy unhandled exceptions in Sentry.
Done
for ConnectionError, Timeout, and HTTPError.
retry errors matching /wp-json/wp/v2 with 500/502/503/504 status codes.
branch — drops, keeps, ConnectionError/MaxRetryError variants, and a negative case
for non-5xx errors.
QA
./run serveordotrunIssue / Card
Fixes #
Screenshots
[If relevant, please include a screenshot.]
Help
QA steps - Commit guidelines