Skip to content

Commit

Permalink
address null purpose check in FileClient GetFiles (Azure#44923)
Browse files Browse the repository at this point in the history
  • Loading branch information
trrwilson authored and tejasm-microsoft committed Jul 22, 2024
1 parent ea8a662 commit d644f5c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sdk/openai/Azure.AI.OpenAI/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Removed an inappropriate null check in `FileClient.GetFiles()` (azure-sdk-for-net 44912)

### Other Changes

## 2.0.0-beta.2 (2024-06-14)
Expand Down
2 changes: 1 addition & 1 deletion sdk/openai/Azure.AI.OpenAI/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/openai/Azure.AI.OpenAI",
"Tag": "net/openai/Azure.AI.OpenAI_fc99a87ba7"
"Tag": "net/openai/Azure.AI.OpenAI_b36dc0424a"
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,13 @@ public override async Task<ClientResult> GetFileAsync(string fileId, RequestOpti
[EditorBrowsable(EditorBrowsableState.Never)]
public override ClientResult GetFiles(string purpose, RequestOptions options)
{
Argument.AssertNotNullOrEmpty(purpose, nameof(purpose));

using PipelineMessage message = CreateGetFilesRequestMessage(purpose, options);
return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
}

[EditorBrowsable(EditorBrowsableState.Never)]
public override async Task<ClientResult> GetFilesAsync(string purpose, RequestOptions options)
{
Argument.AssertNotNullOrEmpty(purpose, nameof(purpose));

using PipelineMessage message = CreateGetFilesRequestMessage(purpose, options);
return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
}
Expand Down
8 changes: 8 additions & 0 deletions sdk/openai/Azure.AI.OpenAI/tests/FileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ public async Task CanUploadAndDeleteFiles()
bool deleted = await client.DeleteFileAsync(file);
Assert.IsTrue(deleted);
}

[RecordedTest]
public async Task CanListFiles()
{
FileClient client = GetTestClient();
OpenAIFileInfoCollection files = await client.GetFilesAsync();
Assert.That(files, Has.Count.GreaterThan(0));
}
}

0 comments on commit d644f5c

Please sign in to comment.