Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendGridClient should be created if there's no valid key #923

Closed
gethari opened this issue Aug 23, 2019 · 2 comments · Fixed by #924
Closed

SendGridClient should be created if there's no valid key #923

gethari opened this issue Aug 23, 2019 · 2 comments · Fixed by #924
Labels
difficulty: easy fix is easy in difficulty type: bug bug in the library

Comments

@gethari
Copy link

gethari commented Aug 23, 2019

SendGridClient accepting null or empty ApiKey values

Create a new SendGridClient with the below code snippet.

Steps to Reproduce

  1. Install Nuget package
  2. Use the below piece of code
var apiKey = string.Empty;
var client = new SendGridClient(apiKey);
string apiKey = null;
var client = new SendGridClient(apiKey);

The client gets created and proceeds for further execution on both the above pieces of code.

Expected Behavior :
Exception must be thrown if the key is null or empty.

Technical details:

  • sendgrid-csharp Version: 9.12.0
  • Platform : Console App , NETFramework
  • .NET Version: Version=v4.6.1

One of my collegue tried this from a FunctionApp as well, this occurs there as well. I guess since there's no validation applied on the apiKey param.

@gethari gethari changed the title SendGridClient should be created if there SendGridClient should be created if there's no valid key Aug 23, 2019
@aevitas
Copy link
Contributor

aevitas commented Aug 24, 2019

Thanks for reporting this - as far as I know this is indeed a bug and the SendGridClient should throw an ArgumentNullException if the apiKey parameter is omitted.

The constructor in question delegates to the SendGridClient(HttpClient httpClient, SendGridClientOptions options) ctor, which does check for options to be non-null, but not any of its members.

Definitely something that should be fixed in my opinion.

@thinkingserious thinkingserious added difficulty: easy fix is easy in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library labels Sep 6, 2019
@childish-sambino
Copy link
Contributor

Taking a look at the submitted PR.

@childish-sambino childish-sambino removed the status: work in progress Twilio or the community is in the process of implementing label Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy fix is easy in difficulty type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants