Git sync issue "failed to write chunk header"

Product: PowerShell Universal
Version: 4.3.4

Just tried to sync with git (local gitlab instance) with builtin client and project access token. Sadly this does not work:

2024-07-31 09:54:53.931 +02:00 [ERR] Failed to sync: failed to write chunk header: The server returned an invalid or unrecognized response
    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 154
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 172
   at LibGit2Sharp.Core.Proxy.git_remote_push(RemoteHandle remote, IEnumerable`1 refSpecs, GitPushOptions opts) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 2246
   at LibGit2Sharp.Network.Push(Remote remote, IEnumerable`1 pushRefSpecs, PushOptions pushOptions) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Network.cs:line 372
   at LibGit2Sharp.Network.Push(Remote remote, String pushRefSpec, PushOptions pushOptions) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Network.cs:line 331
   at LibGit2Sharp.Network.Push(IEnumerable`1 branches, PushOptions pushOptions) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Network.cs:line 255
   at LibGit2Sharp.Network.Push(Branch branch, PushOptions pushOptions) in C:\actions-runner\_work\universal\universal\src\libgit2sharp\LibGit2Sharp\Network.cs:line 216
   at UniversalAutomation.Git.GitService.Push() in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\GitService.cs:line 654
   at UniversalAutomation.GitSyncService.TrySync(GitStatus status, Boolean force, GitSettings settings) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\GitSyncService.cs:line 241
   at UniversalAutomation.GitSyncService.Sync(Boolean force) in C:\actions-runner\_work\universal\universal\src\Universal.Server\Services\GitSyncService.cs:line 105

No clue on what I m missing here…
The local git seems fine. It did commit all the files and the remote is a brand new empty repository waiting for the initial push. Token has read_repository / write_repository privileges.

There’s an open issue from 2021 on the libgit2sharp repo, which is the library PSU uses. Not sure how to take that.

You could try to use the external git client setting. It will run git.exe rather than use litgit2sharp to do the push.

I installed git and did create the repo manually.
Turns out, the project access token has to be maintainer (else it cannot set a default branch/upstream on the gitlab site). Made some more changes to the git config, to assure a valid upstream/remote.

After everything worked manually, I was changing back to the internal PSU git client and it does work now.

1 Like