Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 4

GitHub get-tree API limits and recursivity

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 (https://github.com/websharks/wp-kb-articles/issues/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.

  • /
  • ---- README.md
  • ---- 4,000 files in /
  • ---- /dir1
  • -------- 4,000 files in /dir1
  • ---- /dir2
  • -------- 4,000 files in /dir2

 

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.

3 Replies
Highlighted
Moderator
Message 2 of 4

Re: GitHub get-tree API limits and recursivity

Hi @alhaddad-nasry,

 

Thanks for being here :)

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 from `git 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! 

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Ground Controller Lvl 1
Message 3 of 4

Re: GitHub get-tree API limits and recursivity

Hi!

 

Wouldn't it be nice to include if get tree (recursive) had the support of:

 

*) Max depth. 

*) Simple file pattern matching.

 

BR

 

Niclas

 

Highlighted
Copilot Lvl 2
Message 4 of 4

Re: GitHub get-tree API limits and recursivity

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!