When postmark sends us a bounce we query info about the bounce and that fails. There is some disconnect between what I expect and what postmark provides.
app | [2024-06-16 19:06:25,509] INFO:views.hook_postmark_bounce: postmark bounce hook: message from scanner@apricot.com to scanner@google.com: Automatic email responder (ex: "Out of Office" or "On Vacation").
worker | [2024-06-16 19:06:25,743] WARNING:tasks.process_email_bounce: Unable to retrieve bounce info for bounce id: 2838295837
worker | [2024-06-16 19:06:25,957] ERROR:api._execute: Unhandled exception in task 85677e19-d96b-4ef7-a031-a6cdef798411.
worker | Traceback (most recent call last):
worker | File "/venv/lib/python3.12/site-packages/postmarker/core.py", line 139, in check_response
worker | response.raise_for_status()
worker | File "/venv/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
worker | raise HTTPError(http_error_msg, response=self)
worker | requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.postmarkapp.com/bounces/2838295837
worker |
worker | The above exception was the direct cause of the following exception:
worker |
worker | Traceback (most recent call last):
worker | File "/venv/lib/python3.12/site-packages/huey/api.py", line 391, in _execute
worker | task_value = task.execute()
worker | ^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1711, in runner
worker | return sentry_patched_function(*args, **kwargs)
worker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/sentry_sdk/integrations/huey.py", line 130, in _sentry_execute
worker | reraise(*exc_info)
worker | File "/venv/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1640, in reraise
worker | raise value
worker | File "/venv/lib/python3.12/site-packages/sentry_sdk/integrations/huey.py", line 126, in _sentry_execute
worker | result = func(*args, **kwargs)
worker | ^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/huey/api.py", line 824, in execute
worker | return func(*args, **kwargs)
worker | ^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/huey/contrib/djhuey/__init__.py", line 136, in inner
worker | return fn(*args, **kwargs)
worker | ^^^^^^^^^^^^^^^^^^^
worker | File "/app/as_email/tasks.py", line 227, in process_email_bounce
worker | bounce_details = client.bounces.get(int(bounce["ID"]))
worker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/postmarker/models/bounces.py", line 60, in get
worker | response = self.call("GET", "/bounces/%s" % id)
worker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/postmarker/models/base.py", line 64, in call
worker | return self.client.call(*args, **kwargs)
worker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/postmarker/core.py", line 107, in call
worker | return self._call(method, self.root_api_url, endpoint, data, {header: token}, **kwargs)
worker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker | File "/venv/lib/python3.12/site-packages/postmarker/core.py", line 134, in _call
worker | self.check_response(response)
worker | File "/venv/lib/python3.12/site-packages/postmarker/core.py", line 146, in check_response
worker | raise ClientError(message, error_code=data["ErrorCode"]) from http_error
worker | postmarker.exceptions.ClientError: [1001] Bounce '2838295837' was not found.
When postmark sends us a bounce we query info about the bounce and that fails. There is some disconnect between what I expect and what postmark provides.