Skip to content

Commit

Permalink
Fix NullReferenceException thrown in CreateAddCustomHeadersPolicy whe…
Browse files Browse the repository at this point in the history
…n OpenAIClientOptions is null (#85)

* Fix NullReferenceException thrown when adding the custom headers policy while OpenAIClientOptions is null

* .csproj version increment

---------

Co-authored-by: Travis Wilson <[email protected]>
  • Loading branch information
joseharriaga and trrwilson authored Jun 24, 2024
1 parent 744afe7 commit 0b97311
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 2.0.0-beta.7 (Unreleased)

## Bugs Fixed

- ([#84](https://github.com/openai/openai-dotnet/issues/84)) Fixed a `NullReferenceException` thrown when adding the custom headers policy while `OpenAIClientOptions` is null (commit_hash)

## 2.0.0-beta.6 (2024-06-21)

## Features Added
Expand Down
4 changes: 2 additions & 2 deletions src/Custom/OpenAIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ private static PipelinePolicy CreateAddCustomHeadersPolicy(OpenAIClientOptions o
message.Request.Headers.Set(UserAgentHeaderName, telemetryDetails.ToString());
}
if (!string.IsNullOrEmpty(options.OrganizationId))
if (!string.IsNullOrEmpty(options?.OrganizationId))
{
message.Request.Headers.Set(OpenAIOrganizationHeaderName, options.OrganizationId);
}
if (!string.IsNullOrEmpty(options.ProjectId))
if (!string.IsNullOrEmpty(options?.ProjectId))
{
message.Request.Headers.Set(OpenAIProjectHeaderName, options.ProjectId);
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PackageTags>OpenAI</PackageTags>

<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>beta.6</VersionSuffix>
<VersionSuffix>beta.7</VersionSuffix>

<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit 0b97311

Please sign in to comment.