Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24111

ezcontentstaging: zero bytes http responses are not handled as errors

    Details

      Description

      This is a bit hard to reproduce, as generally speaking, a webserver with php will echo back an http response with status line and a couple of headers even if the php script aborts for any reason.

      But in the case of VikingLine, the network connection might be unreliable to the point where the http response gotten back is completely empty (0 bytes, the socket being closed without a timeout).

      This has been tested by introducing a tcp proxy in between the 2 servers doing REST-API calls, and setting the proxy to immediately drop the connections.

      When this happens, the class eZRESTClient generates a couple of php warnings, but forwards to the upper layer of code a proper, albeit empty, response. And the upper layer of code might just accept an empty response as valid, depending on the design of the API.

      The problem lies in bad error handling inside eZRESTClient::parseHTTTResponse(): instead of returning NULL, it returns an array.
      Fixing that, the symptoms are gone, and empty responses do trigger error messages instead of 'all ok'

        Activity

        Show
        Gaetano Giunta added a comment - PR: https://github.com/ezsystems/ezcontentstaging/pull/42
        Hide
        Paulo Bras (Inactive) added a comment -

        this issue is reproduced when sending sync requests that do not validate response content, such as the move, delete or hide/unhide syncs.

        the details of the issue require that an external tool is used to simulate a broken connection. an alternative way is to simulate the "lost" packages by overriding the content response, in ezrestclient.php::sendRequest().
        steps are:

        • hide any object
        • open the content staging sync list
        • in ezrestclient.php, before line 327. insert before block:

                  if ( $this->Debug > 0 )
                  {
                      $this->ResponsePayload = $rawResponse;
                  }
          

          the line $rawResponse = null;

        • sync the hide operation

        then, whether using an external tool, or the code hack, result in admin page is:

        Event synchronisation action results :
        Object 623 succesfully synchronised to feed CS-target [Event 27]
        

        in notice.log, the response can be checked:

        Notice:    Mar 10 2015 09:11:22
        Received: HTTP/1.1 204 No Content
        Date: Tue, 10 Mar 2015 09:11:22 GMT
        Server: Apache/2.2.22 (Debian)
        X-Powered-By: eZ Publish
        Set-Cookie: eZSESSID=3qnp2t0ac244ggmrjbv8gimpm4; path=/
        Expires: Thu, 19 Nov 1981 08:52:00 GMT
        Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
        Pragma: no-cache
        Content-Length: 0
        Vary: Accept-Encoding
        Connection: close
        Content-Type: text/html
        

        verify the "Received" and "Content-Length" headers

        Show
        Paulo Bras (Inactive) added a comment - this issue is reproduced when sending sync requests that do not validate response content, such as the move, delete or hide/unhide syncs. the details of the issue require that an external tool is used to simulate a broken connection. an alternative way is to simulate the "lost" packages by overriding the content response, in ezrestclient.php::sendRequest(). steps are: hide any object open the content staging sync list in ezrestclient.php, before line 327. insert before block: if ( $this->Debug > 0 ) { $this->ResponsePayload = $rawResponse; } the line $rawResponse = null; sync the hide operation then, whether using an external tool, or the code hack, result in admin page is: Event synchronisation action results : Object 623 succesfully synchronised to feed CS-target [Event 27] in notice.log, the response can be checked: Notice: Mar 10 2015 09:11:22 Received: HTTP/1.1 204 No Content Date: Tue, 10 Mar 2015 09:11:22 GMT Server: Apache/2.2.22 (Debian) X-Powered-By: eZ Publish Set-Cookie: eZSESSID=3qnp2t0ac244ggmrjbv8gimpm4; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 0 Vary: Accept-Encoding Connection: close Content-Type: text/html verify the "Received" and "Content-Length" headers
        Hide
        Bertrand Dunogier added a comment -

        Merged to master@73ac68.

        Show
        Bertrand Dunogier added a comment - Merged to master@73ac68 .
        Hide
        Rui Silva (Inactive) added a comment -

        Sending back.
        The fix for this issue is incomplete.
        Testing this on a 5.3:
        It only verifies for Responses with raw data equal to an empty string ('' in php code) but not to null values.
        According to Paulo Brás's reproduction steps, I assign the raw data to null ($rawResponse = null) but the proposed fix only verifies for empty string and not null:

        if ( $data == '' )
        {
            $this->errorNumber = self::ERROR_NO_DATA;
            $this->errorString = 'No data received from server.';
            return false;
        }
        

        So, if I have a rawResponse=null, I synchronize the 'hide' event and I still get a success message back:

        Event synchronisation action results :
        Object 64 successfully synchronised to feed content [Event 27]
        

        instead of an error message:

        Event synchronisation action results :
        Object 64 to be synchronised to feed content: failure (No data received from server.) [Event 15]
        

        A broader validation for empty data is needed.

        Show
        Rui Silva (Inactive) added a comment - Sending back. The fix for this issue is incomplete. Testing this on a 5.3: It only verifies for Responses with raw data equal to an empty string ('' in php code) but not to null values. According to Paulo Brás's reproduction steps, I assign the raw data to null ($rawResponse = null) but the proposed fix only verifies for empty string and not null: if ( $data == '' ) { $this->errorNumber = self::ERROR_NO_DATA; $this->errorString = 'No data received from server.'; return false; } So, if I have a rawResponse=null, I synchronize the 'hide' event and I still get a success message back: Event synchronisation action results : Object 64 successfully synchronised to feed content [Event 27] instead of an error message: Event synchronisation action results : Object 64 to be synchronised to feed content: failure (No data received from server.) [Event 15] A broader validation for empty data is needed.
        Hide
        Rui Silva (Inactive) added a comment -

        Tested and approved by QA for 4.7, 4.7.1, 5.1, 5.2, 5.3 and master.
        Could not be reproduced on a 5.0 due to EZP-24222.
        Due to the lesser relevancy of this currently working on a 5.0, it was kept out of the scope of this test.

        Show
        Rui Silva (Inactive) added a comment - Tested and approved by QA for 4.7, 4.7.1, 5.1, 5.2, 5.3 and master. Could not be reproduced on a 5.0 due to EZP-24222 . Due to the lesser relevancy of this currently working on a 5.0, it was kept out of the scope of this test.

          People

          • Assignee:
            Unassigned
            Reporter:
            Gaetano Giunta
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: