Skip to content

Undefined array key Message symfony/postmark-mailer #60297

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

Open
turbo124 opened this issue Apr 28, 2025 · 1 comment
Open

Undefined array key Message symfony/postmark-mailer #60297

turbo124 opened this issue Apr 28, 2025 · 1 comment

Comments

@turbo124
Copy link

Symfony version(s) affected

^7

Description

If an email contains attachments > postmark threshold, postmark will return an error with the following payload:

array (
  'message' => 'Request size limit exceeded',
  'request_id' => 'xxxx',
)  

Status Code = 413
However according to this line here:

https://github.com/symfony/postmark-mailer/blob/d11c8ce0ff5974a2ee4a9a3297ba89ecdf6d1952/Transport/PostmarkApiTransport.php#L86

The error message is expecting the key to be Capitalized, causing the error descibed above "Undefined array key 'Message'"

How to reproduce

Add attachments > postmark threshold to an email
Attempt to send
error, Undefined array key 'Message'

Possible Solution

It appears the symfony mailer is expecting API Error codes and the response to always be formatted with

["ErrorCode", "Message"]

However if the response is a Http error code, the payload may not be in this format.

A suggested approach here would be to create a block just for 413 HTTP errors, and return the response based on the output above with the 'message' key

Additional Context

No response

@MatTheCat
Copy link
Contributor

The ErrorCode/Message payload is only documented for 422 responses: https://postmarkapp.com/developer/api/overview#error-codes so the code shouldn''t assume those keys exist for other status codes.

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

4 participants