From f54ea3fa0f1af42b818ed635ff40e136ea21745d Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Sun, 26 Oct 2025 16:14:34 +0100 Subject: [PATCH] Added more guards on MSGraph errors This PR handles empty responses with the status code 204 - No Content. Prior to this PR a 204 response when cancelling an upload session would cause an error due to not being able to parse the empty body. This should get us one step closer to figuring out what is triggering the errors. --- .../Backend/OneDrive/MicrosoftGraphBackend.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs b/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs index 3d20d1e38..28772b4d2 100644 --- a/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs +++ b/Duplicati/Library/Backend/OneDrive/MicrosoftGraphBackend.cs @@ -740,8 +740,20 @@ namespace Duplicati.Library.Backend using (var request = new HttpRequestMessage(HttpMethod.Delete, uploadSession.UploadUrl)) using (var response = await this.m_client.SendAsync(request, false, cancelToken).ConfigureAwait(false)) { - // Note that the response body should always be empty in this case. - await this.ParseResponseAsync(response, cancelToken).ConfigureAwait(false); + try + { + // Note that the response body should always be empty in this case. + if (response.StatusCode != HttpStatusCode.NoContent) + await this.ParseResponseAsync(response, cancelToken).ConfigureAwait(false); + } + catch (Exception parseEx) + { + Log.WriteErrorMessage( + LOGTAG, + "MicrosoftGraphUploadSessionCancelError", + parseEx, + "Error canceling upload session after fragment upload failure"); + } } throw new UploadSessionException(createSessionResponse, fragment, fragmentCount, ex);