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.48k stars 4.81k forks source link

[BUG] Unable to upload a file through UploadFileAsync #43800

Open shivanandpatil512 opened 6 months ago

shivanandpatil512 commented 6 months ago

Library name and version

Azure.AI.OpenAI.Assistants 1.0.0-beta.4

Describe the bug

We have a .Net Core API and we have installed Azure.AI.OpenAI.Assistants 1.0.0-beta.4 nuget package. We are trying to upload a file through .Net Core API using the AssistantsClient.UploadFileAsync it is failing with weird error. Below is the code we tried with

var workingDirectory = AppContext.BaseDirectory;
string filePath = Path.Combine(workingDirectory, fileName);
await File.WriteAllTextAsync(filePath, fileContent);
var fileUploadResponse = await _assistantsClient.UploadFileAsync(filePath, OpenAIFilePurpose.Assistants);
await _assistantsClient.LinkAssistantFileAsync(assistantId, fileUploadResponse.Value.Id);

But, await _assistantsClient.UploadFileAsync(filePath, OpenAIFilePurpose.Assistants); fails with below error

Additional properties are not allowed ('filename' was unexpected)
Status: 400 (Bad Request)

Content:
{
  "error": {
    "message": "Additional properties are not allowed ('filename' was unexpected)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

But same code works fine if we try it in windows form application.

Expected behavior

File should get uploaded to Assistant.

Actual behavior

We get this error

Additional properties are not allowed ('filename' was unexpected)
Status: 400 (Bad Request)

Content:
{
  "error": {
    "message": "Additional properties are not allowed ('filename' was unexpected)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

Reproduction Steps

In any .Net Core API application try the code mentioned 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 @xgithubtriage.

shivanandpatil512 commented 6 months ago

Do we have any ETA on this?

denileo82 commented 6 months ago

same issue here, any solution?

Esmeralda2001 commented 6 months ago

I'm having the exact same issue, is there any update on when Azure will fix this?

nicklasjepsen commented 6 months ago

I had the same issue after updating nugets.

🛠️Downgrading to the following nuget versions is a workaround for the time being🛠️ Azure.AI.OpenAI 1.0.0-beta.16 Azure.AI.OpenAI.Assistants 1.0.0-beta.3

Here's the request that is working fine with 1.0.0-beta.16 and 1.0.0-beta.3: image

And this is after updating to 1.0.0-beta.17 and 1.0.0-beta.4: image

...which is failing with:

{
  "error": {
    "message": "Additional properties are not allowed ('filename' was unexpected)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}
aaronsarkissian commented 6 months ago

Same here, downgrading helped for the moment.