Skip to content

chore: Remove mail.send helpers with on-behalf-of header#436

Merged
JenniferMah merged 4 commits intosendgrid:mainfrom
bjohnson-va:no-send-obo
Sep 24, 2021
Merged

chore: Remove mail.send helpers with on-behalf-of header#436
JenniferMah merged 4 commits intosendgrid:mainfrom
bjohnson-va:no-send-obo

Conversation

@bjohnson-va
Copy link
Copy Markdown
Contributor

The sendgrid documentation (and my own findings) say that the mail.send endpoint
does not support using the on-behalf-of header.

image
Documentation

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.

Fixes

A short description of what this PR does.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

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.
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Jul 20, 2021
Comment thread sendgrid.go Outdated
// 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") {
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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)

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@JenniferMah JenniferMah left a 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!

@JenniferMah JenniferMah changed the title Remove mail.send helpers with on-behalf-of header chore: Remove mail.send helpers with on-behalf-of header Sep 24, 2021
@JenniferMah JenniferMah merged commit 332b5e2 into sendgrid:main Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: code review request requesting a community code review or review from Twilio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants