messages API gives a 500 error.

Issue #147 new
James created an issue

While attempting to load the messages list (/2.1/messages) with basic authentication, it errors out with a 500 error and sometimes, it can load the list of messages. This is the error that is shown in the prod.log.

[2017-05-09 15:39:10] request.INFO: Matched route "_api2_1_messages_list". {"route_parameters":{"_controller":"Atarashii\APIBundle\Controller\MessagesController::getAction","_format":"json","apiVersion":"2.1","_route":"_api2_1_messages_list"},"request_uri":"https://malapi.ateliershiori.moe/2.1/messages"} [] [2017-05-09 15:39:11] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The current node list is empty." at /home/ateliers/public_html/ateliershiori.moe/malapi/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php line 553 {"exception":"[object] (InvalidArgumentException(code: 0): The current node list is empty. at /home/ateliers/public_html/ateliershiori.moe/malapi/vendor/symfony/symfony/src/Symfony/Component/DomCrawler/Crawler.php:553)"} []

Output: {"error":{"code":500,"message":"Internal Server Error"}}

Comments (11)

  1. Michael Johnson

    Based on what you are saying, it sometimes works and sometimes doesn't?

    I personally can't reproduce it right now, but will try again later.

  2. James reporter

    In addition, sending messages do not work. I have to specify an ID greater than 0, which is not mentioned in the documentation. Otherwise it 404s.

    When I send the message, the message sent from the test account does not show up in my main account. It seems as if it's not being sent at all. I tried a request and returns no content. Is this normal?

    POST https://malapi.ateliershiori.moe/2.1/messages

    204 No Content 0 bytes 3.11 secs

    View Request View Response HEADERS

    Accept-Ranges: bytes Cache-Control: no-cache Connection: close Content-Type: text/html; charset=UTF-8 Date: Wed, 10 May 2017 16:38:22 GMT Server: LiteSpeed X-Powered-By: PHP/5.6.30 BODY view raw

    (empty)

  3. Michael Johnson

    Ratan did most of the work on the messages part, so he would know best on how it's supposed to work if the documentation isn't correct.

    Based on reading the source, however, it looks like a successful send should result in a 200 with { "status": "OK" } as the body.

  4. Michael Johnson

    I can't reproduce issues reading the list or individual messages. However, it looks like MAL did change how messages are sent from when the code was originally created.

    I'm working on re-writing the message sending to work with the changes. This may require changes to the sending method for replies, however.

  5. Ratan Dhawtal

    MAL was using 3 id's. Action id, message id and tread id.

    Sending messages can be done with or without an tread id but I just saw that i made a little mistake.

    $id = (int) $request->request->get('id');
            if ($id <= 0) {
                return $this->view(array('error' => 'Invalid thread ID'), 404);
            }
    

    it looks like I forgot to place a check if the request does contain the id before showing the response error.

  6. James reporter

    Also, I have to add that deleting messages with the message id does not work either. It's successful, but it won't delete.

    DELETE https://malapi.ateliershiori.moe/2.1/messages/9470517 204 No Content      0 bytes      2234 ms

    View Request View Response HEADERS Accept-Ranges: bytes Cache-Control: no-cache Connection: close Content-Type: text/html; charset=UTF-8 Date: Wed, 17 May 2017 23:49:34 GMT Server: LiteSpeed X-Powered-By: PHP/5.6.30 BODY view raw (empty)

  7. Michael Johnson

    It's not clearly documented, but you need to pass the action id, not the message id on the delete call.

    I should be pushing a full messages fix and unit tests by end of week if my free time holds up. This will likely only be for the develop branch, not the current stable master branch.

  8. Michael Johnson

    Pushing a fix for most of this now. Note that it doesn't return error states properly right now. If you get a 204, the call probably failed. I'm still going to try and clean more up, but wanted to make the calls at least function. If you can find any weird cases where making the proper calls fails, please update the issue.

  9. Log in to comment