-
Notifications
You must be signed in to change notification settings - Fork 266
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
chore: Remove mail.send helpers with on-behalf-of header #436
Conversation
The sendgrid documentation (and my own findings) say that the mail.send endpoint does not support using the `on-behalf-of` header. [Documentation]( https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of-subuser ) Providing the `NewSendClientSubuser` in this SDK causes wasted time because it sets the expectation that this is possible when it is not. I also added guards to the `GetRequestSubuser` function to prevent people from using it with the mail.send endpoint.
sendgrid.go
Outdated
@@ -21,6 +23,10 @@ func GetRequest(key, endpoint, host string) rest.Request { | |||
// GetRequestSubuser like GetRequest but with On-Behalf of Subuser | |||
// @return [Request] a default request object | |||
func GetRequestSubuser(key, endpoint, host, subuser string) rest.Request { | |||
if strings.Contains(endpoint, "v3/mail/send") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does using the on-behalf-of
with this endpoint throw any error at all? I'm not too sure I like hardcoding this into the logic here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not throw an error, it just silently "fails" by ignoring the header and putting the email on the subuser who owns the API key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(My primary motivation for this change was so that there would be something to test to guard against someone adding this functionality back in)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with getting rid of NewSendClientSubuser
and updating the documentation since that's not really supported but I don't like adding this hardcoded panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shwetha-manvinkurke Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @bjohnson-va!
The sendgrid documentation (and my own findings) say that the mail.send endpoint
does not support using the
on-behalf-of
header.Documentation
Providing the
NewSendClientSubuser
in this SDK causes wasted time because itsets the expectation that this is possible when it is not.
I also added guards to the
GetRequestSubuser
function to prevent people fromusing it with the mail.send endpoint.
Fixes
A short description of what this PR does.
Checklist