Closed Amirshox closed 2 weeks ago
Hey @Amirshox,
thanks for writting in. Sentry adds the sentry-trace
and the baggage
header to outgoing HTTP requests (for its distributed tracing).
Is the Request Header Fields Too Large
coming from Azure or from the OpenAI server?
Can you check your logs if those headers are the problem? Or do you see in your Azure service somehow the incoming requests with its headers?
The SDK has an option trace_propagation_targets
that can be used to prevent adding those headers to certain URLs:
https://docs.sentry.io/platforms/python/configuration/options/#trace-propagation-targets
Hey @Amirshox,
thanks for writting in. Sentry adds the
sentry-trace
and thebaggage
header to outgoing HTTP requests (for its distributed tracing).Is the
Request Header Fields Too Large
coming from Azure or from the OpenAI server?Can you check your logs if those headers are the problem? Or do you see in your Azure service somehow the incoming requests with its headers?
The SDK has an option
trace_propagation_targets
that can be used to prevent adding those headers to certain URLs: https://docs.sentry.io/platforms/python/configuration/options/#trace-propagation-targets
Hey @antonpirker,
Thank you for pointing me in the right direction! It turns out the issue was indeed related to the sentry-trace
and baggage headers added by Sentry.
The 431 Request Header Fields Too Large
error was actually from the OpenAI server.
Using the trace_propagation_targets
option from the Sentry SDK, I was able to prevent these headers from being added to requests sent to specific URLs. This resolved the 431 Request Header Fields Too Large
error without needing to disable Sentry entirely.
Hey @Amirshox, sounds like using trace_propagation_targets
solved your problem, so I am going to close this issue.
If I misunderstood, and you still need more support here, please reopen the issue!
I'm encountering an issue where enabling Sentry in my FastAPI application causes a 431 Request Header Fields Too Large error when requests are processed through Azure API Management (used for load balancing). The problem disappears when Sentry is disabled, indicating that Sentry might be adding additional data to the headers, causing them to exceed size limits.
Here is the relevant Sentry and Azure OpenAI integration code:
Disabling Sentry resolves the issue, and the request is processed as expected.