Possible Regression: + in Branch Name Breaks ref in API #155229
Replies: 5 comments 1 reply
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
As you noted, the + is now being interpreted as a space, which started failing around March 27, 2025—likely due to a recent API update. Looking at the GitHub Status page, there were several incidents around March 20-21, 2025, involving service degradations, but nothing specific to API behavior. However, this timing aligns with your observation of the issue starting between March 18 and March 27. The expected behavior, as per GitHub’s REST API docs for Git references, is that the ref in the URL should be formatted as heads/, and special characters like + should either be handled correctly or require percent-encoding (e.g., + as %2B). Historically, GitHub was more lenient, but it seems they’ve tightened the parsing logic, causing this regression. For now, your workaround of avoiding + in branch names is a good call. To fix existing scripts, you can percent-encode the + as %2B in the API request. So your request would look like:
This should resolve the 404 error. I’d also recommend adding a note to your team’s branching guidelines to stick with safer characters like - or Z, as you mentioned. I’ll flag this to the GitHub team to either restore the previous behavior or update the docs to clarify that + must be encoded. |
Beta Was this translation helpful? Give feedback.
-
|
We have bumped into this as well, even though the I created a test repository to demonstrate the regression. Accessing Using the Note the space in the "message" field of the reported status. We have dozens of repositories in our company and cannot change the branch names as build pipelines are referencing the branches all over the place. So the impact of this bug is significant for us. |
Beta Was this translation helpful? Give feedback.
-
|
The issue seems to be resolved now. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks everyone who reported this, we were able to pass these reports to our team ❤️ . This was the result of a feature flag rollback and I can confirm it is resolved. If you encounter anything related to this, please let us know on this discussion. |
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.
-
Select Topic Area
Bug
Body
🐛 Possible Regression: + in Branch Name Breaks ref in API
Summary
When using the GitHub REST API to retrieve file contents via the
refquery parameter, there's confusion around how special characters are handled. Specifically, branch names containing characters like/and+used to work without explicit encoding, but+is now interpreted as a space (), resulting in404errors for valid branches.Example
Branch name:
API request:
API response:
{ "message": "No commit found for the ref my-branch/with-commits.2025-03-28 0000", "status": "404", "documentation_url": "https://docs.github.com/v3/repos/contents/" }Note that the
+character in therefis interpreted as a space, causing the branch lookup to fail — even though the branch exists.Timing
+in therefwas handled correctly.The change appears to have occurred between these dates.
Our Approach
To avoid issues caused by special character interpretation in the
refparameter, we plan to avoid using+signs in branch names altogether moving forward. We'll adopt safer alternatives (e.g.-orZin place of+) to ensure compatibility with API behavior and URL parsing.Expected Behavior
We believe there may have been a change in the GitHub API’s handling of the
refparameter — previously,+could be used in branch names without explicit encoding, but now it appears to be parsed as a space unless encoded. This shift breaks existing tooling and scripts that previously worked without encoding the+.refescaping should be consistent and well-documented.+) must be percent-encoded.Beta Was this translation helpful? Give feedback.
All reactions