Protected Branch API - Unexpected error


It seems that if you try to check the branch protections of an unprotected branch you get an error message of “Branch not protected”. Is there a reason that you couldn’t just return the object with empty values for each of the protection types? I can alternatively make an extra API request before checking the branch but that seems less than ideal.

I’m firing an event when a review request webhook is received so that I can automatically add additional review requests for the user(s) that are allowed to merge that branch (if any). I was hoping that I could always expect the response of the Get Branch Protection endpoint would always return a similarly shaped object and that I could loop over restrictions->users. If there were none then nobody would need to be added. If I can’t always expect that object to contain an array of users, then I’ll just need to handle this differently I guess. This is all to help my team from having to keep track of who the approved merge users are for each project since that information isn’t currently made available through the UI anywhere.