Skip to content

Report the created or updated pull request when a later step fails - #3784

Open
VISHNU0906 wants to merge 1 commit into
github:mainfrom
VISHNU0906:fix/3756-pr-reviewer-partial-failure
Open

VISHNU0906 wants to merge 1 commit into
github:mainfrom
VISHNU0906:fix/3756-pr-reviewer-partial-failure

Conversation

@VISHNU0906

Copy link
Copy Markdown

Summary

When create_pull_request or update_pull_request fails partway, the error now names the pull request and says it was created or updated, instead of reading as if nothing happened.

Why

Fixes #3756

Thanks for the detailed report @rafe-walker. If the reviewer request failed after the pull request was created, the error had no number or URL, and a retry only got "A pull request already exists". On update, a failure in the draft, reviewer or final read step came back as a bare error even though the title or other edits had already been applied.

What changed

  • create_pull_request: a reviewer failure returns pull request #N was created (<url>), but failed to request reviewers: ....
  • update_pull_request: once a step has changed the pull request (REST edit, draft change, reviewer request), any later failure is prefixed with pull request #N was updated, but .... If nothing was applied yet, the message is unchanged.
  • The result is still an error, since the call didn't do everything it was asked to. I kept it that way rather than returning success with a warning, so existing callers that check isError behave the same.
  • Tests cover create, and on update each step that can fail after an earlier one succeeded, plus the cases where nothing was applied and the old message stays. Each "was updated" case fails if the matching flag update is removed.

MCP impact

  • Tool schema or behavior changed
    Schemas are unchanged. Only the error text of these two tools changes, and only on partial failure.

Prompts tested (tool changes only)

  • Covered by handler tests with mocked REST and GraphQL responses (author requested as reviewer, failed draft conversion, failed final read).

Security / limits

  • No security or limits impact

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed

create_pull_request and update_pull_request make several API calls in
a row. When the reviewer request failed after the pull request had been
created, the error had no number or URL, and a retry only reported
that a pull request for the head branch already exists. On update, a
failure in the draft, reviewer or final read step read as if nothing
had changed, although the earlier edits were applied.

Keep returning an error, but name the pull request and say it was
created or updated when an earlier step already changed it.

Fixes github#3756

Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
@VISHNU0906
VISHNU0906 requested a review from a team as a code owner November 9, 2026 21:36
Copilot AI dynamic review requested due to automatic review settings November 9, 2026 21:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Client-acquisition failures can still return bare errors after earlier updates succeed, leaving callers unaware of changes already applied.

1 open issue
What changed in this PR

This PR addresses #3756 by making partial-failure errors identify pull requests that were already created or updated, helping callers avoid misleading retries.

Changes:

  • Include the created pull request’s number and URL when requesting reviewers fails.
  • Track successful update steps and report earlier changes when a later API step fails, while preserving error status.
  • Add regression tests for partial failures and unchanged messages when no update succeeded.
File Description
pkg/​github/​pullrequests.go Adds partial-success context to create and update error messages.
pkg/​github/​pullrequests_partial_failure_test.go Tests partial-failure reporting and errors before any successful update.

Review effort: Balanced (auto)

Comment on lines +1091 to +1095
stepErrMsg := func(step string) string {
if updated {
return fmt.Sprintf("pull request #%d was updated, but %s%s", pullNumber, strings.ToLower(step[:1]), step[1:])
}
return step
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.

create_pull_request / update_pull_request return an error after the PR was created or edited (reviewer step fails)

2 participants