API to get a tree returns 404 for an empty tree even though it exists #131150
Unanswered
divdavem
asked this question in
Apps, API and Webhooks
Replies: 1 comment
|
💬 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. ⭐ |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Select Topic Area
Bug
Body
Hi,
I am starting this discussion to report a bug with the API to get a tree when the tree is empty.
Here is a sample repository where I reproduced the issue:
https://github.com/divdavem/empty-repository
It contains, in its
masterbranch, a simple commit that contains no file.The sha of the commit is 3fb7891cf06183a3055f1a1a639b50d069a9f036.
If I call the API with the following URL: https://api.github.com/repos/divdavem/empty-repository/git/trees/master?recursive=1
I am getting the following 404 response:
{ "message": "Not Found", "documentation_url": "https://docs.github.com/rest/git/trees#get-a-tree", "status": "404" }This is wrong: the master branch exists, it just contains no file. I would instead expect the following 200 response:
{ "sha": "3fb7891cf06183a3055f1a1a639b50d069a9f036", "url": "https://api.github.com/repos/divdavem/empty-repository/git/trees/3fb7891cf06183a3055f1a1a639b50d069a9f036", "tree": [], "truncated": false }It just contains an empty array in the tree, but otherwise looks like what I get if I call the API with the following URL: https://api.github.com/repos/divdavem/empty-repository/git/trees/readme?recursive=1:
{ "sha": "526bb721ca80fe0169893d0d7b4d436479dea61a", "url": "https://api.github.com/repos/divdavem/empty-repository/git/trees/526bb721ca80fe0169893d0d7b4d436479dea61a", "tree": [ { "path": "README.md", "mode": "100644", "type": "blob", "sha": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "size": 0, "url": "https://api.github.com/repos/divdavem/empty-repository/git/blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" } ], "truncated": false }Could you please fix this issue? Or did I miss something?
Thank you in advance!
All reactions