GitHub get-tree API limits and recursivity #23748
-
Hello, As per the get-tree API (GET /repos/:owner/:repo/git/trees/:tree_sha): “If truncated is true, the number of items in the tree array exceeded our maximum limit. If you need to fetch more items, you can clone the repository and iterate over the Git data locally.” Another online post mentions a GitHub API limit of 1,000 items per tree (wpsharks/wp-kb-articles#76) Is there an exact number of items allowed in a tree? If yes, how many? An example I tried: The root directory containing README.md, 4,000 files, and two subdirectories, containing 4,000 files each.
Calling get-tree API is returning the whole list of 12,003 items, which makes the limit of 1,000 items not possible. The attribute “truncated” is always returned in the response with a value of false. Another question for this example: If recursive was passed to the API with a value of 0, shouldn’t the response exclude the 8,000 files from the two subdirectories? Regardless if recursive is passed with a value of 0 or 1, it is always returning all files in the response. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @alhaddad-nasry, Thanks for being here :slight_smile: We actually have a limit of 100,000 entries. If the The limit was bumped from 1,000 entries to 100,000 in 2014. The issue linked to in the OP may have been working on slightly outdated assumptions. This all said, keep in mind that 100,000 is the current limit, but it could change anytime in the future. I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Hi! Wouldn’t it be nice to include if get tree (recursive) had the support of: *) Max depth. *) Simple file pattern matching. BR Niclas |
Beta Was this translation helpful? Give feedback.
-
Is there a limit when creating a new tree? When doing a POST of a new tree with around 1.5K the tree is created successfully but when attempting with a 20K tree then I get a 502. Have been looking for documentation about this but have not been lucky so far. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
@nadiajoyce, Is there a documentation where it specify the max limit for Tree API? |
Beta Was this translation helpful? Give feedback.
Hi @alhaddad-nasry,
Thanks for being here :slight_smile:
We actually have a limit of 100,000 entries. If the
recursive
parameter is supplied, we will read and return a maximum of 7 MB worth of entries fromgit ls-tree
.The limit was bumped from 1,000 entries to 100,000 in 2014. The issue linked to in the OP may have been working on slightly outdated assumptions.
This all said, keep in mind that 100,000 is the current limit, but it could change anytime in the future.
I hope this helps!