Skip to content
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

fix: Improve pull request creation with better validation and error handling #260

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ivarvd-hldng
Copy link

Problem

When creating pull requests using the GitHub MCP server, users frequently encounter "Unprocessable Entity" errors without clear indication of the underlying cause.

Solution

This PR improves the pull request creation process by:

  1. Adding branch validation to verify both base and head branches exist
  2. Checking for commit differences between branches before attempting PR creation
  3. Implementing detailed error handling with full GitHub API error messages
  4. Adding helpful console logging for debugging

Changes

  • Added validateBranch function to verify branch existence
  • Added getCommitDifference function to check for mergeable changes
  • Enhanced createPullRequest with step-by-step validation
  • Improved error messages with detailed GitHub API responses

Testing

The implementation has been tested with:

  • Non-existent branches
  • Branches without commit differences
  • Valid branch combinations
  • Various GitHub API error scenarios

Related Issues

Closes #259 - GitHub MCP Server Pull Request Creation Error

Notes

This change makes the PR creation process more robust and provides clearer error messages when something goes wrong.

Copy link

@enigmartin enigmartin left a comment

Choose a reason for hiding this comment

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

I think it's obvious we won't want to replace hundreds of lines with "rest of file remains the same..." I think LLM generated pull requests should be created very carefully.

Copy link
Member

@jspahrsummers jspahrsummers left a comment

Choose a reason for hiding this comment

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

I agree. We'd be happy to review a corrected PR.

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.

GitHub API error: Unprocessable Entity when creating PR between two unrelated branches
3 participants