Skip to content

Show ruleset violation details when create_branch fails - #3081

Merged
SamMorrowDrums merged 2 commits into
github:mainfrom
Hashim1999164:fix/create-branch-ruleset-errors
Aug 18, 2026
Merged

Show ruleset violation details when create_branch fails#3081
SamMorrowDrums merged 2 commits into
github:mainfrom
Hashim1999164:fix/create-branch-ruleset-errors

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • create_branch currently returns a compact 422 dump when a repository rule rejects the new name
  • Tool errors now include each nested validation message and the docs URL so agents can recover the way the GitHub UI already explains the rule

Why

Fixes #3080

What changed

  • Format github.ErrorResponse in NewGitHubAPIErrorResponse so nested error messages are visible
  • Cover a ruleset style 422 in the create_branch tests

MCP impact

  • Tool schema or behavior changed
    Error text for GitHub REST failures now includes nested validation messages. Tool schema is unchanged.

Prompts tested (tool changes only)

  • Create a branch named hotfix in a repo whose ruleset requires feature/* and confirm the tool error names the pattern

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

@Hashim1999164
Hashim1999164 requested a review from a team as a code owner August 16, 2026 12:17
@SamMorrowDrums
SamMorrowDrums force-pushed the fix/create-branch-ruleset-errors branch from 8c39205 to 8d7fe37 Compare August 18, 2026 21:51
Hashim1999164 and others added 2 commits August 18, 2026 23:52
create_branch currently forwards the compact 422 dump, which hides
ruleset details the GitHub UI already shows. Unwrap ErrorResponse so agents
can see each validation message and recover.
Limit structured formatting to HTTP 422 responses, sanitize allowlisted validation fields, and omit request, response, and documentation metadata while preserving other error contracts.

Refs github#3080

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SamMorrowDrums
SamMorrowDrums force-pushed the fix/create-branch-ruleset-errors branch from 8d7fe37 to fed13b5 Compare August 18, 2026 21:53
@SamMorrowDrums
SamMorrowDrums merged commit bf47e3e into github:main Aug 18, 2026
13 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.

create_branch branch tool fails with generic message when rule is violated oppose to the Github UI

2 participants