Subtree push error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413

High level problem to solve

Remote (GitLab hosted) hanging with error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 while trying to do 1st subtree push.

Details

Bear with me here, I’m not a git wizard, I’m still learning some of the more complex sides of git.

We have 2 relevant repos to my issue. The 1st is our main Unity Client repo, the 2nd is our SharedTechArtLibrary repo. The shared tech art library is added to the main client repo as a git subtree (note: not a submodule, it’s important to us that the onus is on the pusher, not on the puller as a submodule is due to our builder configuration).

I added the SharedTechArtLibrary repo into our main Unity Client repo as a subtree using this command

git subtree add --prefix Packages/com.autolegends.autolegendssharedlibrary.techart https://gitlab.com/auto-legends-developers/al-sharedtechartlibrary.git main --squash

This adds it to Unity as a local package. That’s all working, I can access the subtree in the project as I would expect. This should enable us to work on the shared library within our main Unity Client project, and then we should be able to use this command to push to the subtree main branch before propagating out changes to our other projects via the Unity Package Manager:

git subtree push --prefix Packages/com.autolegends.autolegendssharedlibrary.techart https://gitlab.com/auto-legends-developers/al-sharedtechartlibrary.git main

It’s my understanding that the 1st subtree push after adding a subtree is so git can sort out the histories. This isn’t actually pushing any files, just writing history data. Our main Unity Client project has a very large history, due to it being an existing project. I’ve tested this in an isolated environment, and my tests seem to match my understanding. The 1st push is larger, all subsequent pushes are small.

However, when I try to do this 1st large push so git can sort the histories I’m getting error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 from the GitLab remote. The full thing looks like this

avea@Machina:/media/avea/dev_null/Unity Projects/auto-legends-prototype$ git subtree push --prefix Packages/com.autolegends.autolegendssharedlibrary.techart https://gitlab.com/auto-legends-developers/al-sharedtechartlibrary.git main
git push using: https://gitlab.com/auto-legends-developers/al-sharedtechartlibrary.git main
Username for 'https://gitlab.com':
Password for 'https://avea@autolegends.com@gitlab.com':
Enumerating objects: 118153, done.
Counting objects: 100% (118153/118153), done.
Delta compression using up to 16 threads
Compressing objects: 100% (29565/29565), done.
Writing objects: 100% (118141/118141), 29.46 GiB | 2.72 MiB/s, done.
Total 118141 (delta 90513), reused 115643 (delta 88448), pack-reused 0
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date

Because of the remote hanging, the additional work I’ve done to the library is not being pushed to the subtree. This isn’t a large file problem that’s solvable with LFS. I’m only trying to push 2 .shader files, 2 .cs files, and 2 materials to the subtree. These are all very small string encoded binary files.

I get a different error if I try the push with SSH

avea@Machina:/media/avea/dev_null/Unity Projects/auto-legends-prototype$ git subtree push --prefix Packages/com.autolegends.autolegendssharedlibrary.techart git@gitlab.com:auto-legends-developers/al-sharedtechartlibrary.git main
git push using: git@gitlab.com:auto-legends-developers/al-sharedtechartlibrary.git main
Enter passphrase for key '/home/avea/.ssh/id_rsa':
Enumerating objects: 118153, done.
Counting objects: 100% (118153/118153), done.
Delta compression using up to 16 threads
Compressing objects: 100% (29565/29565), done.
remote: fatal: pack exceeds maximum allowed size (4.88 GiB)
remote:
remote: ========================================================================
remote:
remote: ERROR: stdin send error: EOF

remote:
remote: ========================================================================
remote:
error: remote unpack failed: index-pack abnormal exit
To gitlab.com:auto-legends-developers/al-sharedtechartlibrary.git
! [remote rejected] 53084dffcf5337eb202bdb06adfae7b805e7ca08 -> main (unpacker error)
error: failed to push some refs to 'gitlab.com:auto-legends-developers/al-sharedtechartlibrary.git'

Various things online tell me to run commands such as git config --global http.postBuffer with a large buffer size on my local machine, but that just causes the subtree push to hang at about 41%. Reducing the number reduces the % that it hangs at. Increasing the number causes this error

fatal: protocol error: bad line length 81924 MiB | 122.98 MiB/s
error: failed to push some refs to 'https://gitlab.com/auto-legends-developers/al-sharedtechartlibrary.git'

Increasing it even further causes an malloc out of memory error.

I also see some stuff online about adjusting the nginx config settings, but I can’t seem to find any way to do that in my repo settings on GitLab’s web portal.

It’s my understanding that there’s a limit to the size of a single pack file can be, that these are auto generated, and that one or more of them is greater than our allowed limit. Again note that there aren’t any large files that I’m trying to push, just some small scripts. Just this subtree history write that git needs to do to allow me to push to my subtree properly, so I don’t think trying to add LFS into the project would do anything (additionally that would be very disruptive to everyone else at the moment, and also require a large history re-write to remove the old non-LFS binaries).

Anyone have any insight into how I can get GitLab to allow me to do my subtree push as I expect (and have tested) to be able to? Once I get past this 1st push it should be smooth sailing…

To anyone who finds this thread in the future:

We were unable to find a solution to this with the current repo. We made a new repo and added the subtree at the beginning of it’s history, preventing the need for the history write entirely. This was a large, disruptive process, but it seemed to be the only way, considering gitlab doesn’t allow us to change the push size to ~25-30GiBs. The subtree push now works as expected, nice and small :slight_smile: