Skip to content

Commit 278735c

Browse files
authored
fix: validate API key is non-empty (#924)
1 parent b5f279c commit 278735c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/SendGrid/SendGridClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public SendGridClient(string apiKey, string host = null, Dictionary<string, stri
111111
public SendGridClient(HttpClient httpClient, SendGridClientOptions options)
112112
{
113113
this.options = options ?? throw new ArgumentNullException(nameof(options));
114+
115+
if (string.IsNullOrWhiteSpace(options.ApiKey))
116+
{
117+
throw new ArgumentNullException(nameof(options.ApiKey));
118+
}
119+
114120
this.client = httpClient ?? CreateHttpClientWithRetryHandler();
115121
if (this.options.RequestHeaders != null && this.options.RequestHeaders.TryGetValue(ContentType, out var contentType))
116122
{

0 commit comments

Comments
 (0)