Skip to content

Mailjet webhook events fail when not grouped #106

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

Closed
prettyv opened this issue May 15, 2018 · 3 comments
Closed

Mailjet webhook events fail when not grouped #106

prettyv opened this issue May 15, 2018 · 3 comments
Assignees

Comments

@prettyv
Copy link

prettyv commented May 15, 2018

Currently (django-anymail v2.2) produces a TypeError when an event type is not configured to be grouped in Mailjet's event trigger settings. This is because the Mailjet webhook handling assumes the body to always be a JSON list containing all events although this is not the case when an event type is not marked to "Group events", which will send each event individually as a JSON dict.
This leads to TypeError: string indices must be integers in webhooks/mailjet.py:57 since esp_event is now a string (key of the event dict).

I guess the reason it is currently implemented like this is that it seems like the official documentation doesn't actually consider this and just says All the events will be delivered to your webhook in a JSON array of event objects. (https://dev.mailjet.com/guides/#endpoint-url)

@medmunds
Copy link
Contributor

Thanks for reporting this. Mailjet event grouping is recommended, but Anymail should support it either way, so this is a bug.

(And you're right: I interpreted the docs the same way you did, and never tested without "Group events" enabled. I should really know better than to trust ESP documentation by now. :-))

@prettyv
Copy link
Author

prettyv commented May 15, 2018

That was quick, thanks a lot! 😄

@medmunds
Copy link
Contributor

Fix released in Anymail v3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants