fix: improve HTTP API error reporting with clean messages#1005
fix: improve HTTP API error reporting with clean messages#1005
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 👀 Review RequirementsThis rule is failing.
🔴 🔎 ReviewsThis rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Pull request overview
This PR improves HTTP API error handling in the CLI by printing a concise, user-friendly error message (including parsed detail and request URL) and avoiding verbose request/response dumps unless --debug is enabled. It also prevents full tracebacks on httpx.HTTPStatusError by exiting cleanly from the CLI entrypoint.
Changes:
- Update
utils.check_for_status()to extractdetailfrom JSON responses and gate request/response dumps behind debug mode. - Add unit tests covering success, JSON-detail errors, plain-text errors, and debug/non-debug output behavior for
check_for_status. - Catch
httpx.HTTPStatusErrorincli.main()to exit with status code 1 without a traceback.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
mergify_cli/utils.py |
Prints clean API error messages and only dumps request/response details in debug mode. |
mergify_cli/tests/test_utils.py |
Adds tests validating new check_for_status output and debug gating behavior. |
mergify_cli/cli.py |
Converts uncaught httpx.HTTPStatusError into a clean exit code (no traceback). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Instead of showing raw JSON and a full Python traceback on API errors, display a clean error message with the parsed detail and URL. Request data and response body are only shown in --debug mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Change-Id: Id5587ccaf13364bf0971c63939a35b1a37ee2ef0 Claude-Session-Id: 09a673a1-bf69-48fa-8bca-73be84bab289
e064971 to
5b88eed
Compare
🧪 CI InsightsHere's what we observed from your CI run for 5b88eed. 🟢 All jobs passed!But CI Insights is watching 👀 |
Instead of showing raw JSON and a full Python traceback on API errors,
display a clean error message with the parsed detail and URL.
Request data and response body are only shown in --debug mode.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com