Report what the forge said when a merge is refused - #15214
Open
ameyypawar wants to merge 1 commit into
Open
Conversation
Merging with a method the repository has disabled failed with only a status code, leaving nothing to act on. The GitHub client's merge path now uses `response_error()`, the helper the rest of the client already reaches for, and that helper surfaces GitHub's `message` rather than the whole JSON object. Bodies carrying `errors` are passed through whole, since that array is the part of a validation failure worth reading. GitLab's merge path had the same gap, in a file that already includes the body at five other sites.
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
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.
🧠 Changes
merge_pull_requestnow reports what GitHub said, not just the status it said it with, by usingresponse_error()— the helper the rest of the client already reaches for, includingupdate_pull_requestten lines above it.response_error()in turn surfaces GitHub'smessagerather than the whole JSON object, so a toast reads405 Method Not Allowed: <sentence>instead of that sentence buried betweendocumentation_urlandstatus. Bodies carryingerrorsare passed through whole, since that array is the part of a validation failure worth reading andmessageis only its headline.GitLab's
merge_merge_requesthad the same gap, in a file that already spells{status} - {error_text}at five other sites. One line.☕️ Reasoning
Merging with a method the repository has disabled fails today with nothing to act on. #8403 describes it as two problems stacked: the picker offers all three methods because nothing fetches
allow_merge_commit/allow_squash_merge/allow_rebase_merge, and the rejection that follows is reduced to a status code. This is the second one. The first is UI work tracked separately in #8654, and greying options out is easier to judge once the failure is legible.The change is small because the intent was already there:
response_error()'s own doc comment says "so GitHub's error message reaches the user", four sites instacks.rsuse it, and #15212 is adding seven more.merge_pull_requestwas the one that missed it.Three things this deliberately does not do:
response_error()itself stays uncovered. Reaching it needs a realreqwest::Response, and there is no mock-HTTP anywhere in the workspace; extracting a one-lineformat!purely to test it seemed worse than the gap. What it delegates to is tested, fallbacks included.response.status()sites inclient.rsare untouched, keeping this a bug fix rather than a sweep. Happy to convert them in one go if you would prefer that.showErrorsends. Preferringmessagenarrows what that carries compared with raw bodies, which is part of whyerrorsis a carve-out rather than the general rule.I have not reproduced a 405 against a repository with the method disabled, so the exact wording GitHub uses is taken from the issue rather than something I have seen. Nothing in the change depends on it.
🎫 Affected issues
Addresses: #8403