Skip to content

Don't treat 409 response to conditional request as an error#20064

Merged
pakrym merged 8 commits intoAzure:masterfrom
pakrym:pakrym/Don-t-treat-409-response-to-conditional-request-as-an-error
Apr 12, 2021
Merged

Don't treat 409 response to conditional request as an error#20064
pakrym merged 8 commits intoAzure:masterfrom
pakrym:pakrym/Don-t-treat-409-response-to-conditional-request-as-an-error

Conversation

@pakrym
Copy link
Copy Markdown
Contributor

@pakrym pakrym commented Apr 2, 2021

Contributes to: #19982

@pakrym pakrym requested a review from KrzysztofCwalina as a code owner April 2, 2021 17:43
@ghost ghost added the Azure.Core label Apr 2, 2021
activity.AddTag("serviceRequestId", message.Response.Headers.RequestId);
if (message.ResponseClassifier.IsErrorResponse(message))
{
activity.AddTag("otel.status_code", "ERROR");
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This allows us to remove the status calculation logic from the AppInsights. PR to follow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread sdk/core/Azure.Core/src/ResponseClassifier.cs Outdated
@pakrym
Copy link
Copy Markdown
Contributor Author

pakrym commented Apr 5, 2021

I talked with @tg-msft and we agreed with a more targeted ResponseClassifier implementation in storage instead of changing the global one.

@pakrym
Copy link
Copy Markdown
Contributor Author

pakrym commented Apr 5, 2021

@kasobol-msft this change would reduce amount of error spans customers see in AppInsights/logs when making CreateIfNotExist calls.

Copy link
Copy Markdown
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

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

This is a very welcome fix.

Comment thread sdk/storage/Azure.Storage.Common/src/Shared/StorageResponseClassifier.cs Outdated
header.Contains(HttpHeader.Names.IfNoneMatch) ||
header.Contains(HttpHeader.Names.IfModifiedSince) ||
header.Contains(HttpHeader.Names.IfUnmodifiedSince);
return !isConditional;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Help new devs wondering what this is for with a comment like:

// We're not considering Container/BlobAlreadyExists as errors when the request has conditional headers.
// Convenience methods like BlobContainerClient.CreateIfNotExists will cause a lot of these responses and
// we don't want them polluting AppInsights with noise.  See RequestActivityPolicy for how this is applied.

@@ -50,7 +50,12 @@ public override bool IsErrorResponse(HttpMessage message)
switch (message.Response.Status)
{
case 409:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we do 412 here as well? We've had requests around that as well, since we expect preconditions to fail during concurrent operations; it also isn't an exceptional situation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looking at https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes I don't see anything I want to eagerly add for now.

…onal-request-as-an-error

# Conflicts:
#	sdk/core/Azure.Core/CHANGELOG.md
#	sdk/core/Azure.Core/src/Azure.Core.csproj
@pakrym pakrym merged commit ac5c483 into Azure:master Apr 12, 2021
@pakrym pakrym deleted the pakrym/Don-t-treat-409-response-to-conditional-request-as-an-error branch April 12, 2021 18:59
@RDavis3000
Copy link
Copy Markdown

Sorry if this is a stupid question but when do these changes get released? How can I tell if they are? Do I need to update anything on my end? Because I am still getting these errors in my ApplicationInsights for BlobBaseClient.Exists()

public void IsError_409_ConditionalResponse(string code, string header, bool isError)
{
var mockRequest = new MockRequest();
mockRequest.Headers.Add("x-ms-error-code", code);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test adds the error code to the request, when it should be on the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants