# Error 400 - bad\_request

**URL:** https://forum.duplicati.com/t/error-400-bad-request/2202
**Category:** Support
**Created:** [January 23, 2018, 10:46pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202 "2018-01-23T22:46:09Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Omnicef](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@Omnicef](https://forum.duplicati.com/u/Omnicef)
#### Post date: [January 23, 2018, 10:46pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/1 "2018-01-23T22:46:09Z")

</div>

The error is as follows:

```
System.Exception: 400 - bad_request: Sha1 did not match data received
   at Duplicati.Library.Main.Operation.BackupHandler.HandleFilesystemEntry(ISnapshotService snapshot, BackendManager backend, String path, FileAttributes attributes)
   at Duplicati.Library.Main.Operation.BackupHandler.RunMainOperation(ISnapshotService snapshot, BackendManager backend)
   at Duplicati.Library.Main.Operation.BackupHandler.Run(String[] sources, IFilter filter)
   at Duplicati.Library.Main.Controller.<>c __DisplayClass16_0.<Backup>b__ 0(BackupResults result)
   at Duplicati.Library.Main.Controller.RunAction[T](T result, String[]& paths, IFilter& filter, Action`1 method)
   at Duplicati.Library.Main.Controller.Backup(String[] inputsources, IFilter filter)
   at Duplicati.Server.Runner.Run(IRunnerData data, Boolean fromQueue)

```

Version: 2.0.2.1\_beta\_2017-08-01  
Running as a service  
Destination is BackBlaze B2

Any thoughts?

---

<div class="post-metadata">

### Author: ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)
#### Post date: [January 24, 2018, 8:38pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/2 "2018-01-24T20:38:32Z")

</div>

Are you running Duplicati on a Mac?

If so, then even though it’s not exactly the same error, you may find moving to a canary version newer than 2.0.2.8 OR setting the `FH_DISABLE_APPLECC=1` environment variable before starting Duplicati might help (all as described here):

> [@400 - bad\_request: invalid sha1](https://forum.duplicati.com/t/400-bad-request-invalid-sha1/907):
>
> Starting with upgrade to the most recent version, I have been getting this error every time I run my backup to Backblaze B2. I am using version 2.0.2.9 on MacOS High Sierra. My backup of the same data to a Samba share is still working fine. Failed: 400 - bad\_request: invalid sha1: 8116318EB12EE2C849998DB54671A67C97A8D481000000000000000000000000 Details: System.Exception: 400 - bad\_request: invalid sha1: 8116318EB12EE2C849998DB54671A67C97A8D481000000000000000000000000 at Duplicati.Library.Main…

Oh, and I edited your post by putting “~~~” before and after the error message to make it easier to read.

---

<div class="post-metadata">

### Author: ![Omnicef](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@Omnicef](https://forum.duplicati.com/u/Omnicef)
#### Post date: [January 24, 2018, 9:44pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/3 "2018-01-24T21:44:00Z")

</div>

This is not running on a Mac, it’s running on either Server 2008 R2 or Server 2012, (I have this error on approximately 6 machines). It sounds like FH\_DISABLE\_APPLECC=1 is a Mac only thing?

---

<div class="post-metadata">

### Author: ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)
#### Post date: [January 25, 2018, 10:28pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/4 "2018-01-25T22:28:43Z")

</div>

> [@Omnicef](#):
>
> It sounds like FH\_DISABLE\_APPLECC=1 is a Mac only thing?

Yep, I believe you are correct. I incorrectly assumed that since the only other user I found with a similar error was on a Mac that you were as well, sorry about that.

Unfortunately, what I’m seeing in the code makes it look like some problem (in this case the SHA1 error) with your destination (in this case B2) is causing the HandleFilesystemEntry() code to abort assuming the connection to the backend has been lost.

The way the code is written I believe the error is happening elsewhere but being reported as coming from the HandleFilesystemEntry() code block. @kenkendk, assuming I’m reading that correctly is there a reason a 400 - bad\_request error like that doesn’t trigger a retry?

> <https://github.com/duplicati/duplicati/blob/a4aa62facfe0268ab1b171d687d89d7893b4d612/Duplicati/Library/Main/Operation/BackupHandler.cs#L945-L949>

---

<div class="post-metadata">

### Author: ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)
#### Post date: [January 26, 2018, 9:08am UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/5 "2018-01-26T09:08:58Z")

</div>

> [@Omnicef](#):
>
> It sounds like FH\_DISABLE\_APPLECC=1 is a Mac only thing?

You can disable the `FasterHashing` stuff on Windows (and all other OS’s) with:

```plaintext
export FH_LIBRARY=Managed

```

But for Windows, it should not make problems, because it would otherwise use the native CryptoNG system calls (part of .Net, so not likely to fail).

I have put up a test tool to verify that FasterHashing actually works:

> **[FasterHashingTester.zip](https://www.dropbox.com/s/damds35n6ubwfc3/FasterHashingTester.zip?dl=0)**
>
> Shared with Dropbox

> [@JonMikelV](#):
>
> assuming I’m reading that correctly is there a reason a 400 - bad\_request error like that doesn’t trigger a retry?

Where do you see that? The `backend.HasDied` exception is only thrown _after_ the retries are depleted.

---

<div class="post-metadata">

### Author: ![Omnicef](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@Omnicef](https://forum.duplicati.com/u/Omnicef)
#### Post date: [January 26, 2018, 4:00pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/6 "2018-01-26T16:00:21Z")

</div>

How do I export FH\_LIBRARY=Managed on windows when it is run as a service? I don’t see any documentation on that. Thank you so much for all of your help!

---

<div class="post-metadata">

### Author: ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)
#### Post date: [January 26, 2018, 9:10pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/7 "2018-01-26T21:10:24Z")

</div>

> [@kenkendk](#):
>
> Where do you see that? The backend.HasDied exception is only thrown after the retries are depleted.

😊 I didn’t see that anywhere - I was being lazy and didn’t follow through all the places that HandleFilesystemEntry might have been used.

* * *

> [@Omnicef](#):
>
> How do I export FH\_LIBRARY=Managed on windows when it is run as a service

Normally I’d say use a `--run-script-before` parameter to call a batch file that just does a `set FH_LIBRARY=Managed`, but in this case I’m not sure if that will do the trick.

If it doesn’t, you can run `sysdm.cpl` from the command line to open the standard Windows “System Properties” window, select the “Advanced” tab, then click on the “Environment Variables…” button in the lower right and from there you can add it to the “System variables” section.

* * *

Did you try running the FasterHashingTest.zip file?

Here’s what it said about my machine:

```plaintext
Optimal implementation is: CNG
Performing basic tests
Performing tests with non-zero offsets
Testing performance with 64b block
                 CNG: 1010941 hashes/second
             Managed: 901949 hashes/second
Testing performance with 100kb blocks
                 CNG: 1716639 hashes/second
             Managed: 820466 hashes/second
Testing performance with 64b blocks and 5 byte offset
                 CNG: 1083937 hashes/second
             Managed: 690961 hashes/second
Testing performance with 100kb blocks and 5 byte offset
                 CNG: 1696017 hashes/second
             Managed: 863182 hashes/second
Testing multithreadded execution to wiggle out any shared state problems

```

* * *

Note that on my machine my Avast antivirus flagged it as “a very rare file” and stopped the execution with the following message:  
 ![image](https://forum.duplicati.com/uploads/default/original/2X/e/e1aeabc19b92ebc6d997cfcc5f17a63ae2a06023.png)

Note that even when flagging the file as “trusted” I still couldn’t run it w/out waiting for Avast to get back to me OR disabling my AV.

---

<div class="post-metadata">

### Author: ![Omnicef](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@Omnicef](https://forum.duplicati.com/u/Omnicef)
#### Post date: [January 31, 2018, 5:16pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/8 "2018-01-31T17:16:17Z")

</div>

These are the results of FasterHashingTest:

```
Optimal implementation is: CNG
Performing basic tests
Performing tests with non-zero offsets
Testing performance with 64b block
                 CNG: 490450 hashes/second
             Managed: 409254 hashes/second
Testing performance with 100kb blocks
                 CNG: 561544 hashes/second
             Managed: 402171 hashes/second
Testing performance with 64b blocks and 5 byte offset
                 CNG: 497450 hashes/second
             Managed: 392568 hashes/second
Testing performance with 100kb blocks and 5 byte offset
                 CNG: 586881 hashes/second
             Managed: 429487 hashes/second
Testing multithreadded execution to wiggle out any shared state problems

```

I am trying that environment variable now as well.

---

<div class="post-metadata">

### Author: ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)
#### Post date: [January 31, 2018, 8:11pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/9 "2018-01-31T20:11:16Z")

</div>

Thanks for the FasterHashingTest results (by the way, I edited your post by putting “~~~” before and after the results to make them a bit easier to read).

I’m not seeing anything that would indicate an error, but it’s @kenkendk’s tool so he’d know better than I would.

---

<div class="post-metadata">

### Author: ![Omnicef](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/o/f04885/32.png) [@Omnicef](https://forum.duplicati.com/u/Omnicef)
#### Post date: [February 7, 2018, 9:22pm UTC](https://forum.duplicati.com/t/error-400-bad-request/2202/10 "2018-02-07T21:22:49Z")

</div>

Is it possible that this is the same issue that the program rclone was having?

> <https://github.com/ncw/rclone/issues/533>
