{"record":{"id":"8f832b865026ee64","repo":"duplicati/duplicati","slug":"failed-to-parse-response-8f832b","errorCode":null,"errorMessage":"Failed to parse response","messagePattern":"Failed to parse response","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Duplicati/Library/Backend/Backblaze/B2.cs","lineNumber":370,"sourceCode":"\n            request.Headers.TryAddWithoutValidation(\"Authorization\", uploadUrlData.AuthorizationToken);\n            request.Headers.Add(\"X-Bz-Content-Sha1\", sha1);\n            request.Headers.Add(\"X-Bz-File-Name\", _urlencodedPrefix + Utility.UrlEncoding.UrlPathEncode(remotename));\n            request.Content = new StreamContent(timeoutStream);\n\n            request.Content.Headers.Add(\"Content-Type\", \"application/octet-stream\");\n            request.Content.Headers.Add(\"Content-Length\", timeoutStream.Length.ToString());\n\n            var response = await _httpClient.UploadStream(request, cancelToken).ConfigureAwait(false);\n            response.EnsureSuccessStatusCode();\n\n            var rdata = await response.Content.ReadAsStreamAsync(cancelToken).ConfigureAwait(false);\n\n            UploadFileResponse fileinfo;\n            using (var tr = new StreamReader(rdata))\n            await using (var jr = new Newtonsoft.Json.JsonTextReader(tr))\n                fileinfo = new Newtonsoft.Json.JsonSerializer().Deserialize<UploadFileResponse>(jr)\n                    ?? throw new Exception(\"Failed to parse response\");\n\n            // Delete old versions\n            if (_filecache!.ContainsKey(remotename))\n                await DeleteAsync(remotename, cancelToken).ConfigureAwait(false);\n\n            _filecache[remotename] =\n            [\n                new FileEntity\n                {\n                    FileID = fileinfo.FileID,\n                    FileName = fileinfo.FileName,\n                    Action = \"upload\",\n                    Size = fileinfo.ContentLength,\n                    UploadTimestamp = (long)(DateTime.UtcNow - Utility.Utility.EPOCH).TotalMilliseconds\n                }\n            ];\n        }\n        catch (Exception ex)","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/Duplicati/Library/Backend/Backblaze/B2.cs#L352-L388","documentation":"Thrown in PutAsync (B2.cs:370) after a successful file upload. The HTTP status was 2xx (EnsureSuccessStatusCode passed), but deserializing the response body as UploadFileResponse using Newtonsoft.Json returned null. This means the body was empty, contained literal JSON null, or did not match any properties of UploadFileResponse.","triggerScenarios":"PutAsync completes the HTTP upload to the B2 upload URL. response.Content.ReadAsStreamAsync provides the body. A StreamReader + Newtonsoft.Json.JsonTextReader feeds into JsonSerializer.Deserialize<UploadFileResponse>. If the result is null, the upload response could not be parsed.","commonSituations":"Network intermediary (proxy, CDN, firewall) truncating or replacing the upload response; B2 API returning an unexpected response format during maintenance; response encoding issue (e.g. double-gzip); Duplicati version incompatible with a B2 API schema change.","solutions":["Retry the upload to rule out transient response corruption or B2 maintenance","Inspect network path for proxies or appliances intercepting upload traffic to the B2 upload URL","Update Duplicati to the latest version in case of B2 API response schema changes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var maxRetries = 3;\nfor (int attempt = 0; attempt < maxRetries; attempt++)\n{\n    try { await backend.PutAsync(remotename, stream, cancelToken); break; }\n    catch (Exception ex) when (ex.Message == \"Failed to parse response\" && attempt < maxRetries - 1)\n    {\n        // Upload HTTP succeeded but response was unparseable; retry the upload\n        await Task.Delay(TimeSpan.FromSeconds(Math.Pow(2, attempt)), cancelToken);\n    }\n}","preventionTips":["Wrap PutAsync calls in a retry loop since upload response parsing failures can be transient","Log the raw HTTP response body when this error occurs to diagnose proxy or encoding issues","Verify no intermediary modifies upload responses from B2"],"tags":["b2","upload","deserialization","api-response"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}