Skip to content

Add 404 exception handling in BlobPayloadStore.DownloadAsync#534

Merged
YunchuWang merged 6 commits intomainfrom
copilot/fix-purge-all-instances-warnings
Dec 10, 2025
Merged

Add 404 exception handling in BlobPayloadStore.DownloadAsync#534
YunchuWang merged 6 commits intomainfrom
copilot/fix-purge-all-instances-warnings

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

Improves error handling when downloading large payloads from blob storage by catching 404 errors and providing descriptive exceptions.

Note: The reported 404 warnings during PurgeAllInstancesAsync likely originate from Microsoft.Azure.DurableTask.AzureStorage (the backend storage provider), not this SDK. However, this change improves diagnostics for the large payload externalization path.

Changes

  • Catch RequestFailedException with 404 status in DownloadAsync
  • Re-throw as InvalidOperationException with blob/container context
  • Preserve original exception for debugging
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.NotFound)
{
    throw new InvalidOperationException(
        $"The blob '{name}' was not found in container '{container}'. " +
        "The payload may have been deleted or the container was never created.",
        ex);
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://crl3.digicert.com:443/DigiCertCSRSA4096RootG5.crl
    • Triggering command: /usr/bin/dotnet dotnet restore rgo/bin/grep grep -l (http block)
  • http://crl3.digicert.com:443/DigiCertTrustedG4TimeStampingRSA4096SHA2562025CA1.crl
    • Triggering command: /usr/bin/dotnet dotnet restore rgo/bin/grep grep -l (http block)
  • http://crl3.digicert.com:443/NETFoundationProjectsCodeSigningCA2.crl
    • Triggering command: /usr/bin/dotnet dotnet restore rgo/bin/grep grep -l (http block)
  • http://crl3.digicert.com:443/sha2-assured-ts.crl
    • Triggering command: /usr/bin/dotnet dotnet restore rgo/bin/grep grep -l (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>DurableTaskClient.PurgeAllInstancesAsync causing a lot of warnings: 404 The specified container does not exist.</issue_title>
<issue_description>When running the code below I get a lot of warnings.

Code:

public async Task PurgeAllInstances(DurableTaskClient client, DateTime fromDate, DateTime toDate, IEnumerable<OrchestrationRuntimeStatus> runtimeStatus)
  {  
      PurgeInstancesFilter filter = new PurgeInstancesFilter(fromDate, toDate, runtimeStatus);
      PurgeInstanceOptions purgeInstanceOptions = new PurgeInstanceOptions();
      PurgeResult purgeResult = await client.PurgeAllInstancesAsync(filter, purgeInstanceOptions, CancellationToken.None).ConfigureAwait(false);
  
  }

Warning:

Severity level: Warning, Message: Error response [9c10a80f-58e6-4378-bcb8-035c7b056089] 404 The specified container does not exist. (00.0s)
Server:Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id:b37ab98c-b01e-0009-1e8e-36c22c000000
x-ms-client-request-id:9c10a80f-58e6-4378-bcb8-035c7b056089
x-ms-version:2025-05-05
x-ms-error-code:ContainerNotFound
Date:Mon, 06 Oct 2025 06:59:59 GMT
Content-Length:225
Content-Type:application/xml

Attatch to this issue the log (containing many warnings) for a single purge.

query_data.csv

</issue_description>

<agent_instructions>investigate and make fix if this is indeed a bug</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 5, 2025 22:20
…ner existence first

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
…adAsync

Co-authored-by: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix warnings in DurableTaskClient.PurgeAllInstancesAsync Add 404 exception handling in BlobPayloadStore.DownloadAsync Dec 5, 2025
Copilot AI requested a review from YunchuWang December 5, 2025 22:31
@YunchuWang YunchuWang marked this pull request as ready for review December 10, 2025 22:13
Copilot AI review requested due to automatic review settings December 10, 2025 22:13
Copy link
Member

@YunchuWang YunchuWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified locally change work as expected, signing off

@YunchuWang YunchuWang merged commit ad96233 into main Dec 10, 2025
11 checks passed
@YunchuWang YunchuWang deleted the copilot/fix-purge-all-instances-warnings branch December 10, 2025 22:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error diagnostics in the Azure Blob Storage payload store by adding specific exception handling for 404 (Not Found) errors during payload download operations. While the reported issue mentions warnings during PurgeAllInstancesAsync, the PR author notes those likely originate from the backend storage provider (Microsoft.Azure.DurableTask.AzureStorage), not this SDK. Nevertheless, this change enhances diagnostics for the large payload externalization path.

Key Changes:

  • Added try-catch block in BlobPayloadStore.DownloadAsync to catch RequestFailedException with 404 status
  • Re-throws as InvalidOperationException with descriptive error message including blob name and container context
  • Preserves original exception as inner exception for debugging purposes

Comment on lines +139 to 145
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 or the container was never created.",
ex);
}
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new exception handling logic for 404 errors in DownloadAsync lacks test coverage. Consider adding a test that verifies:

  1. A RequestFailedException with 404 status is properly caught
  2. The resulting InvalidOperationException contains the expected error message with blob name and container
  3. The original RequestFailedException is preserved as the inner exception

This would ensure the error handling behavior is maintained across future changes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DurableTaskClient.PurgeAllInstancesAsync causing a lot of warnings: 404 The specified container does not exist.

3 participants