Creating new tree with GIT Data API returns 502


I use git data api for pushing some json files into repository for a long time now, but some time ago I started to face some problems regarding new tree creation. Here’s the situation:

I create new tree with 6 json files in it of type “blob” and “mode” 100644. Each file has around 12mb of size, converted to utf-8. As before i didnt have any problems with it (was pushing 4 files, less size), now when i’m pushing more files sometimes (irregulary) i’m getting this kind of error:

"statusCode": 502,
    "body": {
        "message": "Server Error"
    "headers": {
        "server": "",
        "date": "Wed, 05 Sep 2018 15:36:03 GMT",
        "content-type": "application/json",
        "content-length": "32",
        "connection": "close",
        "etag": "\"<e_tag>\"",
        "x-github-request-id": "<request_id>"

 Can this be really related to total tree size? Or can there be some other reasons? What is important, it occurs irregularly, sometimes creation goes well, but it’s like 1-3 creations and im getting the 502 back. Are there any limits regarding file sizes, total tree size? I didnt find anything in the documentation.

1 Like

502 [Bad gateway] seems like a temporary error to me.

EDIT: Are you using the correct endpoint?

Yes, nothing has changed:

POST /repos/:owner/:repo/git/trees

I never had any problem with this endpoint, everything worked fine until my files have grown. Doesn’t seem like a temporary error tho as it lasts for like 2 weeks for now - i manage to create 3 trees and commit them, then i have to wait like 30 mins because github responses with 502 and over and over… 

1 Like

I’m facing the same. I’m able to create a tree which is around 1.5K files but fails for a tree which is 20K so I think the root cause is around the amount of files in the new tree. I haven’t found documentation about what are the limits though.


The same problem seems to happen to one of our client.

We are using the GitHub API through the @ocktokit/rest Node module to automatically sync our client data from our app to a GitHub repository.

For some reason, this client (which has a lot of content) always get a 502 Server error when trying to create a new tree, while creating the individual blobs (8 images and 430 text files) that should constitute the end commit works fine.

Is there any known limitation to the size of the created tree using the 

POST /repos/:owner/:repo/git/trees


Kind regards,


Yea, we just encountered this issue as well. Also possible that we are hitting the limits about git. We have about 9K files all just flat in the root folder. At first we noticed that we would get 502’s occasionally, then frequently, and now 100% of the time – gradual service degradation over a span of a few days.

yea this sounds uncannily similar to what we are seeing as well