Skip to content

fix: report fork-PR resolution errors instead of a traceback - #56

Merged
vitali87 merged 5 commits into
mainfrom
fix/fork-ref-error-handling
Aug 31, 2026
Merged

fix: report fork-PR resolution errors instead of a traceback#56
vitali87 merged 5 commits into
mainfrom
fix/fork-ref-error-handling

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Summary

  • pr-split split '#999' (or user:branch) printed a Python stack trace when fetch_fork_pr / fetch_fork_branch raised: nothing in split caught GitOperationError and there is no top-level handler. The call is now wrapped and the prepared ErrorMsg printed with exit code 1.
  • fetch_fork_pr reported a same-repo PR as "not found or is not from a fork". It now raises a distinct PR_NOT_FROM_FORK message telling the user to pass the head branch name instead; a deleted fork (head.repo null) still reports PR_NOT_FOUND.

Test plan

  • New tests: CLI reports the error without a traceback; same-repo PR gets the specific message
  • uv run ruff check / ruff format --check clean
  • uv run pytest -q — 446 passed

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 37 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d436ff5d-1ce8-4a8d-bfbc-81a257411e67

📥 Commits

Reviewing files that changed from the base of the PR and between d6c8930 and 19a65fe.

📒 Files selected for processing (5)
  • pr_split/cli.py
  • pr_split/exceptions.py
  • pr_split/git_ops/prs.py
  • tests/test_cli_coverage.py
  • tests/test_git_prs_coverage.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

This change improves fork-reference failures by showing clean CLI errors and by distinguishing same-repository pull requests from deleted or missing forks. Runtime coverage confirmed that ordinary fork-resolution errors now exit cleanly and that same-repository and deleted-fork responses receive the intended messages. A malformed GitHub pull-request response still escapes as an uncaught JSON decoding exception, leaving users without a useful error message.

Confidence Score: 4/5

Not ready to merge until malformed pull-request responses are converted into the same user-facing resolution error path.

The affected command path was exercised with an authored runtime harness, which reproduced the uncaught JSON decoding exception while also confirming the intended clean handling for normal resolution errors.

Files Needing Attention: pr_split/git_ops/prs.py needs to normalize malformed GitHub response data before it reaches the CLI handler; pr_split/cli.py catches only the project exception hierarchy.

T-Rex T-Rex Logs

What T-Rex did

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (2)

  1. pr_split/git_ops/prs.py, line 99 (link)

    P1 Malformed pull-request responses bypass CLI error handling

    fetch_fork_pr calls json.loads without converting malformed GitHub output into a GitOperationError. A response such as not-json therefore makes split #44 terminate with an uncaught JSONDecodeError and no user-facing error, because split only catches PRSplitError. Normalize decoding and malformed-payload failures to a project error so this path receives the same clean CLI handling as other pull-request resolution failures.

    Artifacts

    Focused fork-reference runtime harness source

    • Authored Python harness that mocks GitHub and Git boundaries while invoking the actual Typer CLI and fork resolver paths, providing the exact executable reproduction.

    Base revision fork-reference runtime output

    • Executed harness output from the PR base revision, showing the original uncaught resolver error and pre-change combined fork message.

    PR #56 head fork-reference runtime output

    Focused PR #56 test output

    • Executed the three committed focused tests for CLI resolver handling, same-repository classification, and deleted forks; all passed.

    View artifacts

    T-Rex Ran code and verified through T-Rex

  2. pr_split/git_ops/prs.py:99; propagation gap pr_split/cli.py:735-739

    P1 Malformed GitHub pull-request payload bypasses fork-reference CLI error handling

    • Bug
      • split #44 with a malformed GitHub API response (not-json) exits with an uncaught JSONDecodeError and emits no user-facing error. The runtime harness confirms the exception is not a PRSplitError, so the new handler does not handle it. Typer's in-process test runner captured no traceback text, but the unhandled exception itself is proven.
    • Cause
      • fetch_fork_pr calls json.loads(raw) without translating json.JSONDecodeError into GitOperationError; split catches only PRSplitError.
    • Fix
      • Wrap JSON decoding and payload extraction in fetch_fork_pr and raise GitOperationError(ErrorMsg.PR_NOT_FOUND(number=pr_number)) (or another explicit API-response error) from JSONDecodeError, KeyError, and malformed structural values.

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix: report fork-PR resolution errors in..." | Re-trigger Greptile

@vitali87

Copy link
Copy Markdown
Owner Author

Addressed the Greptile finding: fetch_fork_pr now converts a malformed API response (invalid JSON, non-object, missing head/base) into GitOperationError(PR_RESPONSE_INVALID), so it reaches the same clean CLI error path. Parametrised test added.

@vitali87
vitali87 force-pushed the fix/fork-ref-error-handling branch from c64678a to 1707218 Compare August 30, 2026 12:25

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Greptile has paused reviews on this repository — it used its 100 free open-source review credits for this billing period. Reviews resume automatically on September 2. To continue before then, an organization admin can keep reviews running past the free credits — those bill as normal usage.

Errors from fetch_fork_pr / fetch_fork_branch (PR not found, fetch
failed) escaped split as raw GitOperationError tracebacks. Catch them
and print the prepared message. Also distinguish a same-repo PR from a
missing one so the user is told to pass the branch name instead.
@vitali87
vitali87 force-pushed the fix/fork-ref-error-handling branch from 1707218 to da2e12f Compare August 30, 2026 13:05
@vitali87
vitali87 merged commit f8f48a0 into main Aug 31, 2026
4 checks passed
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.

1 participant