postalserver / postal

📮 A fully featured open source mail delivery platform for incoming & outgoing e-mail

Home Page:https://postalserver.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API /messages/message returns 500 if _expansions != array and doc is outdated

gsommavilla opened this issue · comments

Hi, I migrated from 2.1.4 to 3.3.2.

Before migration I checked API doc and changelog and saw that API ruotes and behaviour didn't change.

However, after migration, when testing api/v1/messages/message I realized that the _expansions parameter is not allowed anymore to be a boolean, but only a list of strings with message fields.

My application used the API with "_expansion":true and received a 500 Internal error (while it was working ok in 2.1.4).

If support for expansions as boolean is actually dropped, I suggest to

  1. add a control in app/controllers/legacy_api/messages_controller.rb to check if expansions is actually a list of strings and, it that's the case, return an informative 400 Bad Request/malformed request syntax or something like that (instead of the 500 disorienting message)

  2. update the API doc https://apiv1.postalserver.io/controllers/messages/message.html removing the following sentence about _expansions parameter: "You can send true rather than array to receive all expansions."

Thanks!