Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.2k stars 4.55k forks source link

[BUG] [Azure.AI.OpenAI] Validation error at #/dataSources/0/AzureCognitiveSearch/parameters/authentication/APIKey/APIKey: Field required #41138

Open thomas-christiansen opened 6 months ago

thomas-christiansen commented 6 months ago

Library name and version

Azure.AI.OpenAI beta.12 https://github.com/Azure/azure-sdk-for-net/blob/Azure.AI.OpenAI_1.0.0-beta.12/sdk/openai/Azure.AI.OpenAI/README.md

Describe the bug

All the sudden when I call GetChatCompletionsAsync using the method described in the readme I get this error: Validation error at #/dataSources/0/AzureCognitiveSearch/parameters/authentication/APIKey/APIKey: Field required

This just started happening today. I havent made any changes to the code or the search index. When I try to run the reqeust in the Azure AI Studio it works just fine.

What is going on?

Here is my code

        var client = new OpenAIClient(new Uri(_apiBase), new AzureKeyCredential(_apiKey!));

        var primeText = "...";

        AzureCognitiveSearchChatExtensionConfiguration searchExtensionConfig = new()
        {
            SearchEndpoint = new Uri(_searchEndpoint),
            IndexName = _searchIndexName,
            Authentication = new OnYourDataApiKeyAuthenticationOptions(_searchKey),
            DocumentCount = 10,
            Strictness = 1,
            RoleInformation = primeText
        };

        var chatCompletionsOptions = new ChatCompletionsOptions()
        {
            DeploymentName = _deploymentId,
            Messages =  {
                new ChatRequestSystemMessage(primeText)
            },
            AzureExtensionsOptions = new AzureChatExtensionsOptions()
            {
                Extensions = { searchExtensionConfig }
            },
            Temperature = 0.8f

        };

        var response = await client.GetChatCompletionsAsync(chatCompletionsOptions);

Expected behavior

I should run without errors as it has been doing until today

Actual behavior

The error has started to occur - has any thing changed? I'm not seeing a new nuget package, the latest is v12-beta

Reproduction Steps

The code is in the description

Environment

No response

github-actions[bot] commented 6 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.

github-actions[bot] commented 6 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.

thesnake666 commented 6 months ago

Unfortunately I have the same error with the same client code and library version. Also for me this behavior just started happening today! Please, help us. Thanks

WueF commented 6 months ago

For me exactly the same issue occured today for the first time, without changing anything to code. Library version is exactly the same.

freistli commented 6 months ago

I experienced the same issue, it suddenly happened several hours ago with my released binary code, nothing changed from code or configuration. 10 hours ago everything still worked.

It turns to be Azure OpenAI API changes its behavior and returns 400 error directly.

LucGosso commented 6 months ago

Same here, similar code, but version beta11. It started 3 days ago, then it didnt return any result from search first. 2 days ago it worked, yesterday on my important demonstration, it didnt work. Same error, about missingkey.

I guess something changed in azure endpoint?

PS i do get this on 2 different subscriptions, resources in Sweden

kokuljose commented 6 months ago

Same issue is happening for my two client project for past 5+ hours which is live. Azure.AI.OpenAI version is 1.0.0-beta.12

horakmi2 commented 6 months ago

Same Issue here

mejerrytech commented 6 months ago

Same here.

yzweig commented 6 months ago

Same here

sonfer commented 6 months ago

I didn't make any changes to my codes that were working yesterday. But it stopped working properly.

LucGosso commented 6 months ago

How do we report this to Azure?

Do you guys have the same? this is Health of the Openai service in portal

image

LucGosso commented 6 months ago

I pay for services but can report it when its not working, great deal

image

126463 commented 6 months ago

Same issue since this morning, just before a demo.

LucGosso commented 6 months ago

Filed an issue via X and got a free technical ticket, got the answer from Azure support:


Thank you for connecting with us. I have gone through all the details you shared; I would like to thank you for briefly describing the complete issue. To start troubleshooting your issue, I would suggest that can you please roll back to the previous Azure OpenAI Package using dotnet. You can use this command for rolling it back to the beta.6 version.

Command: dotnet add package Azure.AI.OpenAI --version 1.0.0-beta.6


If someone wants to try before me ... let us know

kokuljose commented 6 months ago

@LucGosso I have downgraded the system to beta-11, yet the issue remains unresolved. It seems that downgrading to beta 6 will necessitate making corresponding changes to the code, particularly in relation to the message defined in azure.ai.openai. This will require careful consideration and thorough implementation to ensure the successful resolution of the error.

brunobmo commented 6 months ago

Same with me. Noticed that stopped working yesterday...

claymartin74 commented 6 months ago

I have the same issue today... Started happening in production (no deployment).

edwardkuo commented 6 months ago

I get the same issue. So nuget version is bug?

126463 commented 6 months ago

I get the same issue. So nuget version is bug?

I think so, everything works fine with Playground - Chat Completions with custom data.

MahdiSheikhi commented 6 months ago

I observed that the system wasn't functioning correctly since yesterday.

However, I've implemented a temporary fix with the following steps:

I changed the authentication from using an API key:

Authentication = new OnYourDataApiKeyAuthenticationOptions(myApiKey),

to using a System Assigned Managed Identity:

Authentication = new OnYourDataSystemAssignedManagedIdentityAuthenticationOptions(),

These changes have resolved the issue for now.

PaulCousinsTTEducation commented 6 months ago

To get the system managed identity workaround to be successful you have to enable "Both" under the keys blade of the search service. I also had to assign both the "Contributor" and "Search Index Data Contributor" roles. Only then did it work for me. This was using the beta.12 version.

thesnake666 commented 6 months ago

This morning, without any changes neither in code nor in configuration, the service is back to work :-)

thomas-christiansen commented 6 months ago

I'm getting a different error now: 'NoneType' object has no attribute 'get'

This happens when I include the "Assistant" response to the message history. This has not been an issue before, so this looks like another bug that have been introduced. I know this is a preview library, but come on. You could at least keep it in sync with the azure openai service....

brunobmo commented 6 months ago

Still the same APIKey error. No changes today. I will go try the workaround proposed using Identity

moremanu commented 6 months ago

Same issue since yesterday. Tried with two different solutions, different approaches same error.

freistli commented 6 months ago

The Azure OpenAI service starts getting to normal, but AzureExtensionsContext.Messages doesn't return Citations. I'm going to create another bug

LucGosso commented 6 months ago

@freistli yes, i have the same behavior now. No Citations.

result.Value.Choices[0].Message.AzureExtensionsContext.Messages.Any()//no citation here, broken service

freistli commented 6 months ago

I'm getting a different error now: 'NoneType' object has no attribute 'get'

This happens when I include the "Assistant" response to the message history. This has not been an issue before, so this looks like another bug that have been introduced. I know this is a preview library, but come on. You could at least keep it in sync with the azure openai service....

I hit the same issue "NoneType" when using "Assistant" response yesterday, but today it backs to normal without code changing.

freistli commented 6 months ago

@freistli yes, i have the same behavior now. No Citations.

result.Value.Choices[0].Message.AzureExtensionsContext.Messages.Any()//no citation here, broken service

@LucGosso I created the new bug here: https://github.com/Azure/azure-sdk-for-net/issues/41241

thesnake666 commented 6 months ago

Yes, confirm, the result is ok for content but the citations field is null

LucGosso commented 6 months ago

Out of nothing all working now as expected, citation too, without code changes. Do we know what caused this service break?

thomas-christiansen commented 6 months ago

Can confirm. It is working as it should again.

I wonder when we can expect a stable version of Azure OpenAI and these components....

GraysonQuartech commented 3 months ago

Currently getting this error.... if anyone found a solution where i can still use the api key to validate that would be great. currently doing this.

const client = new OpenAIClient(AZURE_ENDPOINT, new AzureKeyCredential(AZURE_API_KEY));