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

Issue parsing delivery delays from Postmark #392

Open
jmduke opened this issue Aug 21, 2024 · 2 comments
Open

Issue parsing delivery delays from Postmark #392

jmduke opened this issue Aug 21, 2024 · 2 comments

Comments

@jmduke
Copy link
Contributor

jmduke commented Aug 21, 2024

Thank you for anymail! I am a huge, huge fan :)

I wanted to report a bug with how the backend parses delay notifications from Postmark. Here's a trivial stack trace:

KeyError: 'ErrorCode'
  File "anymail/backends/postmark.py", line 65, in parse_recipient_status
    error_code = one_response["ErrorCode"]

AnymailRequestsAPIError: Invalid Postmark API response format
KeyError: 'ErrorCode'
Postmark API response 200 (OK):
{
  "Message": "Message accepted, but delivery may be delayed.",
  "MessageID": "38360f97-ff7f-44b2-bcd1-5ea94ff2af00",
  "SubmittedAt": "2024-08-05T02:03:37.0951168Z",
  "To": "[email protected]"
}

With this being the relevant code. Seems straightforward enough, but I didn't know if Anymail has encountered/fixed this in any other ESPs. If so, happy to cargo-cult that approach and submit a fix.

@medmunds
Copy link
Contributor

Thanks for the report, and for including the full Postmark API response.

It looks like this is a new response format that doesn't follow Postmark's docs (which imply ErrorCode is always present, and is 0 when there is no error).

I guess Anymail's Postmark backend needs to detect this case, in the code you linked. We should probably handle it using the successful-send if error_code == 0 logic that follows, but change status="sent" to status="queued" when the Message includes "delivery may be delayed". PR definitely welcome.

@jmduke
Copy link
Contributor Author

jmduke commented Aug 21, 2024

Wonderful. This isn't high-priority on my end (I've only seen ~10 emails with this coding in the millions I've sent over Postmark), but I have put it on my list to try and tackle.

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