Skip to content

fix(submit): do not mistake GitHub 5xx errors for a missing PR - #43

Open
amustafa wants to merge 1 commit into
am/shell-hook-cd-filefrom
am/submit-pr-survey-503
Open

fix(submit): do not mistake GitHub 5xx errors for a missing PR#43
amustafa wants to merge 1 commit into
am/shell-hook-cd-filefrom
am/submit-pr-survey-503

Conversation

@amustafa

Copy link
Copy Markdown
Owner

What

sr submit no longer offers to create PRs that already exist when GitHub's API has a bad moment.

Why

The PR survey ran gh pr view <branch> and treated any exit code 1 as "no PR exists". But gh also exits 1 on server failures — during a real GitHub 503 spell, roughly a third of the survey calls failed per pass, each misread as "this branch has no PR", and submit prompted to create PRs for branches deep in review. Saying yes would at best fail on the duplicate; the prompt itself was the bug.

How

  • ghPRForBranch now classifies the failure by gh's stderr, not its exit code:
    • no pull requests found → genuinely no PR (nil, nil, as before)
    • HTTP 5xx → transient server failure, retried up to 3 attempts with 1s/2s backoff so one flaky call doesn't poison a whole stack survey
    • anything else (auth, rate limits) → propagates, so submit stops with "failed to check PR status" instead of offering a duplicate
  • The gh stub in prepare_test.go now prints the real no pull requests found message — a bare exit 1 is exactly the ambiguity the fix refuses to interpret.
  • New tests: unit tests for both stderr classifiers, plus stub-gh tests of the real function (503-then-success retries and returns the PR; no-PR returns nil without error; a 401 surfaces as an error).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d47a7693-edfb-42bb-a83c-d9d261f9624e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@amustafa amustafa closed this Aug 19, 2026
@amustafa
amustafa force-pushed the am/submit-pr-survey-503 branch from 009ac14 to 0d57b0d Compare August 19, 2026 14:56
@amustafa amustafa reopened this Aug 19, 2026
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.

2 participants