Unable to clone repository after corrupt file added. Curl 56 failure when receiving data.
Asked by Sparky:

I have a repository hosted on Bitbucket cloud. I have been able to clone this repository, commit to it, submit pull requests and merge without issue. I use Visual Studio 2019 Professional and the extension "Visual Studio Bitbucket Extension" (created by MistyK). This extension is outdated and is no longer supported, however, it does continue to clone repositories without issue. I also use Git Bash to verify that Visual Studio is not the problem. In the last couple of weeks, I have been receiving the following error:

"Error: RPC failed; curl 56 Failure when receiving data from the peer"

"Error encountered while cloning the remote repository: Git failed with a fatal error."

"CloneCommand.ExecuteClone"

Normally I have received this error if my Cryptographic network provider wasn't set to "Secure Channel". Everything is configured properly as I am able to successfully clone other repositories without issue. I started suspecting that maybe the repository itself had an issue with it. I created a brand new repository and started slowly committing files back into it and determined that there is one major culprit:

I have the following package installed into my solution:

Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1.nupkg

It appears this package has several files that seem to cause the repository to become "corrupt" and no longer allow me to clone it once the files are merged into the repository. I have never had any issues with this package in the past and the package has never been updated in my solution.

If I delete the problematic file(s) from the repository, I am still unable to clone. If I revert any pull requests on the repository that include the problematic files, it does not resolve my issue. The only solution I have found so far is to completely recreate the repository, lose all history, and only add non-problematic files to it. This does allow me to successfully clone the repository until I add the files in question. This is concerning as these files worked in the past and I'm concerned that the files may have become corrupt over time. I can live without the files but I cannot figure out how to salvage my repository without recreating it.

I also use a remote connection to my computer which is protected by a firewall, requiring a VPN connection. Some installed software that may interfere include Sophos Endpoint Agent along with any security settings IT may have configured. Again, I haven't had these problems in the past and I have confirmed that IT hasn't changed any settings since then (including Sophos).

I am able to successfully clone the repositories (including the problematic one) outside of my remote connection. The largest repository I have is about 80MB in size.


Answers:
author: Theodora Boudale
body: Hi [@Sparky](/t5/user/viewprofilepage/user-id/3465417),

This error means that there is some issue that prevented the data from being received during the cloning process, and it is typically caused by a network setting, firewall, VPN client, or anti-virus that is terminating the connection before all data has been transferred. If the error only occurs when using a specific network or computer and you are able to clone this repo using a different network or computer, then something in that specific network or computer may be terminating the connection.

We have the following guide on troubleshooting network issues, which may be useful:

* <https://confluence.atlassian.com/bbkb/troubleshooting-network-issues-389778693.html>

Based on the error, I assume you're using HTTPS to clone the repo. Are you able to clone it using SSH?

I'm not familiar with the package included in your repo, but if you want to try removing any files and see if that solves the issue, you can use BFG to remove certain files completely from the repo's history:

* <https://rtyley.github.io/bfg-repo-cleaner/>

You mentioned that you deleted the problematic files, but then you also mentioned that certain PRs still include them. It sounds like you may have committed the files' deletion in the repo, which will not remove these files from the repo's history. Using BFG you can completely remove certain files from a repository's history.

I would strongly recommend taking a backup of the repo before making any changes with BFG, as the process includes destructive operations. Additionally, push any changes you make with BFG to a newly created empty repo first (instead of your existing one) and see if you are able to clone this repo then.

Kind regards,  
Theodora

comments: author: Sparky
body: [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086)

I'm not sure how our network specifically plays a role into this. I was able to clone the repository without issue outside of our firewall. It turns out, Visual Studio uses a different .gitignore file than the standard .gitignore supplied by Bitbucket. This was causing Visual Studio to push the .vs folder, packages folder, and several other files (259 total) that should not have been on the repository. Some of these files were causing the corruption on the server side of the repository. You are correct, the history + the files were the problem. I was able to go through BFG and manually delete the problematic folders/files, recommit, merge and push everything back to the repository with the history changes. I verified that I was able to clone the salvaged repository and all history showed no trace of the bad files. Thank you!


author: Theodora Boudale
body: Hi [@Sparky](/t5/user/viewprofilepage/user-id/3465417),

You are very welcome, I'm glad to have helped and it's good to hear that the issue has been resolved!

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud