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

'str' object has no attribute 'get()' #836

Closed
eshanholtz opened this issue Sep 10, 2019 · 0 comments · Fixed by #839
Closed

'str' object has no attribute 'get()' #836

eshanholtz opened this issue Sep 10, 2019 · 0 comments · Fixed by #839

Comments

@eshanholtz
Copy link
Contributor

Issue Summary

When sending a message that contains a Ganalytics member of a TrackingSettings object, sg.send() makes calls to .get() to build the associated JSON data. This results in a .get() call being made on the Ganalytics members, some of which are the primitive str type and do not have the .get() method. The line causing the error can be found here.

Steps to Reproduce

  1. run temp.py:
# using SendGrid's Python Library
# https://github.com/sendgrid/sendgrid-python
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
from sendgrid.helpers.mail.tracking_settings import TrackingSettings
from sendgrid.helpers.mail.ganalytics import Ganalytics

message = Mail(
    from_email='[email protected]',
    to_emails='[email protected]',
    subject='Sending with Twilio SendGrid is Fun',
    html_content='<strong>and easy to do anywhere, even with Python</strong>')
try:
    tracking_settings = TrackingSettings()
    tracking_settings.ganalytics = Ganalytics(enable=True, utm_medium="email")
    message.tracking_settings = tracking_settings
    sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
    response = sg.send(message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e.message)

Either the module should enforce the use of the Utm_ modules, or check for the presence of primitive str types.

Technical details:

  • sendgrid-python Version: master (latest commit: 610e933)
  • Python Version: 3.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant