-
Notifications
You must be signed in to change notification settings - Fork 36
Fix MCP error handling in create_pull_request handlers #10931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+1,376
−10
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…st_branch When patch generation fails, return error response instead of throwing. This ensures Claude Code CLI can properly display the error to the agent, instead of the tool call failing silently. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This workflow tests that the agent receives clear error messages when create_pull_request fails, instead of treating it as a missing tool. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate failure to call create-pull-request method
Fix MCP error handling in create_pull_request handlers
Jan 21, 2026
Contributor
|
@copilot merge main, format lint |
Contributor
Author
Contributor
|
@copilot add tests |
…r and pushToPullRequestBranchHandler Tests verify that handlers return error responses (not throw) when patch generation fails, and that error responses include helpful details for users. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Added comprehensive tests for error handling in commit 4d3fbc8. Added 4 new tests that verify:
All 2890 tests pass. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Investigation: Agent not calling create-pull-request
Problem Analysis
missing_toolerrorRoot Cause
When the
create_pull_requestsafe-output tool fails (e.g., when patch generation fails because no commits were made), the handler throws an Error instead of returning an error response. This causes the MCP tool call to fail, but Claude Code CLI doesn't properly display MCP error responses - it just fails silently. The agent interprets this as the tool not existing and reports it as a "missing_tool".Code Location:
actions/setup/js/safe_outputs_handlers.cjslines 231-236Solution Implemented
createPullRequestHandlerto return error responses instead of throwingpushToPullRequestBranchHandlerto return error responses instead of throwingisError: trueflag in responseFiles Modified
actions/setup/js/safe_outputs_handlers.cjs- Fixed error handling in both handlersactions/setup/js/safe_outputs_handlers.test.cjs- Added 4 new tests for error handling.github/workflows/test-create-pr-error-handling.md- Test workflow.github/workflows/test-create-pr-error-handling.lock.yml- Compiled test workflowTesting
npm test- 143 test files, 2890 tests passedcreatePullRequestHandler > should return error response when patch generation fails (not throw)createPullRequestHandler > should include helpful details in error responsepushToPullRequestBranchHandler > should return error response when patch generation fails (not throw)pushToPullRequestBranchHandler > should include helpful details in error responsetest-create-pr-error-handlingmake fmt- All files formattedmake lint- 0 issuesNext Steps
The test workflow can be manually triggered to verify that:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.