-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
.Net: Bug: Azure OpenAI client fails with 401 when throttling #8929
Comments
looks like a bug in the underlying Azure.AI.OpenAI 2.0.0-beta.5, I reported it here Azure/azure-sdk-for-net#46109 including a workaround |
@RogerBarreto I'm assigning this to you, can you monitor the issue Devis created an pick up the fix when it becomes available. |
The original issue was closed, setting this as complete as the original issue is addressed and will be available automatically to Semantic Kernel package in a future release. |
@RogerBarreto the outstanding open issue here is the reliance on a pre-release package with a noticeable (quite annoying) bug that impacts all SK consumers. Rather than waiting for the Azure SDK fix to propagate to SK and SK fix to propagate to consumers, I'd suggest that SK includes a workaround as soon as possible, e.g. by injecting a delegating handler: internal sealed class AuthFixHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Headers.TryGetValues("Authorization", out var headers) && headers.Count() > 1)
{
request.Headers.Authorization = new AuthenticationHeaderValue(
request.Headers.Authorization!.Scheme,
request.Headers.Authorization.Parameter);
}
return base.SendAsync(request, cancellationToken);
}
} |
### Motivation and Context - Fix #8929
## Motivation and Context (Why the change? What's the scenario?) Temporary workaround for Azure OpenAI SDK bug - service throttling handled incorrectly and causing incorrect HTTP status error See: * Azure/azure-sdk-for-net#46109 * microsoft/semantic-kernel#8929 * #855
…sts (#876) ## Motivation and Context (Why the change? What's the scenario?) When retrying requests after throttling, the Azure OpenAI SDK is sending malformed requests, with multiple `Authorization` headers, which are rejected by the Azure OpenAI service with a `401 (Unauthorized)` error code, leading to an exception in the SDK. See - Azure/azure-sdk-for-net#46109 - microsoft/semantic-kernel#8929 - #855 ## High level description (Approach, Design) Inject a policy to fix malformed HTTP headers. Functional test included, to verify the fix.
When using
AzureOpenAITextEmbeddingGenerationService
SK client and sending too many requests, the Azure service throttling leads to a "401 Unauthorized" error instead of "429 Too Many Requests".I inspected the HTTP requests and noticed that the internal retry logic is sending a malformed request during retries. It appears to be adding the Authorization header twice (with the same token), e.g.
Code to repro:
Output:
The text was updated successfully, but these errors were encountered: