Does the GitHub API not respect branch protection rule bypass for file deletion in protected branches? #149844
Replies: 1 comment
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I'm encountering an odd behavior when using the GitHub API to delete files from a repository that has branch protection rules in place. When attempting to delete a file in a protected path via the API, the operation fails, even though the user has the correct permissions, is in the bypass list for the protection rule, and is using a Personal Access Token (PAT) with the appropriate permissions (repo and write:repo).
However, when performing the same action via the GitHub web interface, I am able to delete the file without issues, as the user is in the bypass list of the branch protection rules, which should allow modifying the branch even when there are protection rules on that path.
This behavior leads me to ask: Is it a bug that the GitHub API does not respect branch protection rule bypass when attempting to delete files? Based on my experience, the API should allow bypassing protection rules for actions like this, given that the user has the correct permissions. What’s curious is that the bypass works for all other actions via the API (e.g., commits, pushes, etc.), but not for deleting files specifically in protected paths.
As a temporary workaround, I’ve found that disabling the branch protection rule allows the API to delete the file without issue. However, this isn't ideal, and I’d prefer to understand whether this behavior is a limitation of the API or something that’s expected to be fixed.
Has anyone else experienced this behavior, or could provide more clarity on why this is happening?
Thank you in advance for any responses or updates.
Beta Was this translation helpful? Give feedback.
All reactions