From 3cde95c4e8c035deb0092975da77fbf4259949ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:10:03 +0000 Subject: [PATCH 1/3] Initial plan From 5ef32736a6d9897675a63a96c6b6a29902effb86 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:20:57 +0000 Subject: [PATCH 2/3] Fix 404 warnings in BlobPayloadStore.DownloadAsync by checking container existence first Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com> --- .../PayloadStore/BlobPayloadStore.cs | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs b/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs index 9edced26..5cab79fd 100644 --- a/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs +++ b/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs @@ -2,7 +2,9 @@ // Licensed under the MIT License. using System.IO.Compression; +using System.Net; using System.Text; +using Azure; using Azure.Core; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Models; @@ -115,22 +117,41 @@ public override async Task DownloadAsync(string token, CancellationToken throw new ArgumentException("Token container does not match configured container.", nameof(token)); } + // Check if the container exists first to avoid 404 warnings from Azure SDK + Response containerExistsResponse = await this.containerClient.ExistsAsync(cancellationToken); + if (!containerExistsResponse.Value) + { + throw new InvalidOperationException( + $"The blob container '{container}' does not exist. " + + "The payload may have been deleted or the container was never created."); + } + BlobClient blob = this.containerClient.GetBlobClient(name); - using BlobDownloadStreamingResult result = await blob.DownloadStreamingAsync(cancellationToken: cancellationToken); - Stream contentStream = result.Content; - bool isGzip = string.Equals( - result.Details.ContentEncoding, ContentEncodingGzip, StringComparison.OrdinalIgnoreCase); + try + { + using BlobDownloadStreamingResult result = await blob.DownloadStreamingAsync(cancellationToken: cancellationToken); + Stream contentStream = result.Content; + bool isGzip = string.Equals( + result.Details.ContentEncoding, ContentEncodingGzip, StringComparison.OrdinalIgnoreCase); + + if (isGzip) + { + using GZipStream decompressed = new(contentStream, CompressionMode.Decompress); + using StreamReader reader = new(decompressed, Encoding.UTF8); + return await ReadToEndAsync(reader, cancellationToken); + } - if (isGzip) + using StreamReader uncompressedReader = new(contentStream, Encoding.UTF8); + return await ReadToEndAsync(uncompressedReader, cancellationToken); + } + catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.NotFound) { - using GZipStream decompressed = new(contentStream, CompressionMode.Decompress); - using StreamReader reader = new(decompressed, Encoding.UTF8); - return await ReadToEndAsync(reader, cancellationToken); + throw new InvalidOperationException( + $"The blob '{name}' was not found in container '{container}'. " + + "The payload may have been deleted.", + ex); } - - using StreamReader uncompressedReader = new(contentStream, Encoding.UTF8); - return await ReadToEndAsync(uncompressedReader, cancellationToken); } /// From 334eb4b43eb9da050d0d455851cd204e0b48947f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:27:57 +0000 Subject: [PATCH 3/3] Simplify exception handling for 404 errors in BlobPayloadStore.DownloadAsync Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com> --- .../PayloadStore/BlobPayloadStore.cs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs b/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs index 5cab79fd..ec66a44b 100644 --- a/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs +++ b/src/Extensions/AzureBlobPayloads/PayloadStore/BlobPayloadStore.cs @@ -117,15 +117,6 @@ public override async Task DownloadAsync(string token, CancellationToken throw new ArgumentException("Token container does not match configured container.", nameof(token)); } - // Check if the container exists first to avoid 404 warnings from Azure SDK - Response containerExistsResponse = await this.containerClient.ExistsAsync(cancellationToken); - if (!containerExistsResponse.Value) - { - throw new InvalidOperationException( - $"The blob container '{container}' does not exist. " + - "The payload may have been deleted or the container was never created."); - } - BlobClient blob = this.containerClient.GetBlobClient(name); try @@ -149,7 +140,7 @@ public override async Task DownloadAsync(string token, CancellationToken { throw new InvalidOperationException( $"The blob '{name}' was not found in container '{container}'. " + - "The payload may have been deleted.", + "The payload may have been deleted or the container was never created.", ex); } }