Skip to content

fix: improve HTTP API error reporting with clean messages#1005

Open
jd wants to merge 1 commit intomainfrom
devs/jd/worktree-better-error/Id5587ccaf13364bf0971c63939a35b1a37ee2ef0
Open

fix: improve HTTP API error reporting with clean messages#1005
jd wants to merge 1 commit intomainfrom
devs/jd/worktree-better-error/Id5587ccaf13364bf0971c63939a35b1a37ee2ef0

Conversation

@jd
Copy link
Member

@jd jd commented Mar 6, 2026

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

Copilot AI review requested due to automatic review settings March 6, 2026 15:14
@mergify mergify bot had a problem deploying to Mergify Merge Protections March 6, 2026 15:14 Failure
@mergify
Copy link
Contributor

mergify bot commented Mar 6, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 👀 Review Requirements

This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@mergify mergify bot requested a review from a team March 6, 2026 15:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 extract detail from 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.HTTPStatusError in cli.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
@jd jd force-pushed the devs/jd/worktree-better-error/Id5587ccaf13364bf0971c63939a35b1a37ee2ef0 branch from e064971 to 5b88eed Compare March 6, 2026 15:29
@mergify mergify bot had a problem deploying to Mergify Merge Protections March 6, 2026 15:30 Failure
@mergify mergify bot requested a review from a team March 6, 2026 15:57
@mergify
Copy link
Contributor

mergify bot commented Mar 6, 2026

🧪 CI Insights

Here's what we observed from your CI run for 5b88eed.

🟢 All jobs passed!

But CI Insights is watching 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants