Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialization policy consider 304 as an error leading to a telemetry exception being recorded #32454

Open
1 of 6 tasks
Apokalypt opened this issue Jan 7, 2025 · 4 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Apokalypt
Copy link

  • Package Name: core-client
  • Package Version: 1.9.2
  • Operating system: Windows 10 + Darwin 24.1
  • nodejs
    • version: 18.20.4
  • browser
    • name/version:
  • typescript
    • version:
  • Is the bug related to documentation in

Describe the bug
The deserialization policy implemented in @azure/core-client considers any request with a status code not between 200 and 300 as an error which seems to be a good option. However, due to this behaviour each time an API answers 304 we are seing in Application Insights an exception which is not an expected behavior as a 304 is clearly expected

To Reproduce

  1. Setup instrumentation with @azure/monitor-opentelemetry and register azure SDK instrumentation
  2. Try to download a file from blob storage by providing the condition ifNoneMatch in order to receive 304
  3. Look at

Expected behavior
HTTP calls with status code equals to 304 should not generate a telemetry exception

Screenshots

  • Screenshot from Application insights showing the exception telemetry with the 304 status code
    Image
  • Screenshot of the deserialization policy
Image

Additional context
N/A

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 7, 2025
@xirzec
Copy link
Member

xirzec commented Jan 7, 2025

My understanding is that 304 gets modeled as an error since the spec for downloadBlob only specifies responses for 200 and 206: https://github.com/Azure/azure-rest-api-specs/blob/b478dcdabacb37945ff89daa0eda1ae1afc98db4/specification/storage/data-plane/Microsoft.BlobStorage/stable/2025-01-05/blob.json#L2698

Since the default response is a StorageError for all unspecified status codes, the deserialization policy throws a RestError. Because the client doesn't handle this, it forwards the error to the consumer.

@xirzec xirzec closed this as completed Jan 7, 2025
@xirzec xirzec reopened this Jan 7, 2025
@xirzec
Copy link
Member

xirzec commented Jan 7, 2025

Sorry, GitHub helpfully sent my response while I was in the middle of typing it. I don't think we can change the API contract for Storage methods that use conditional requests, but I am curious how AppInsights is hooking this, if it's on exceptions being created/thrown that's going to cause problems whenever exceptions are used for control flow

@xirzec xirzec added the Monitor - Exporter Monitor OpenTelemetry Exporter label Jan 7, 2025
@xirzec xirzec added the Client This issue points to a problem in the data-plane of the library. label Jan 7, 2025
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jan 7, 2025
@JacksonWeber
Copy link
Member

JacksonWeber commented Jan 7, 2025

@xirzec @Apokalypt If a REST error is thrown and bubbles up to the top level of the application, I'd expect OpenTelemetry to create an exception record that we then export to Application Insights the same way as any unhandled exception. This seems like it'd be expected in the event of a "real" REST error. So apart for some special logic for 304s, I'm not sure if this would be considered "unexpected" behavior. Should be solvable by catching 304s on the client side for now, but strange to have that response code count as an "exception" at all.

@Apokalypt
Copy link
Author

@JacksonWeber when you are talking about "client side" is it on Azure's SDK code or on my code when I use the library ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor - Exporter Monitor OpenTelemetry Exporter question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants