Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77799

REST web service request exceptions are not included in server logs

XMLWordPrintable

    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-77799-m401
    • MDL-77799-master
    • Hide
      1. Ensure debugging is set to at least MINIMAL.
      2. Request the following URL from your Moodle server: /webservice/rest/server.php?wstoken=&wsfunction=fake&moodlewsrestformat=json
        • Expected: No change from before - the JSON result should include a representation of the exception that occurs (it's an invalid token error).
      3. Check the web server error log
        • Expected: There should be a new line added to the log, which contains the exception name and stack trace, among other information. The below example is from my local Apache server.

      [2023-03-30 14:41:00.622915 GMT] [php:notice] [pid 6564:tid 1216] [client 127.0.0.1:50599] REST exception handler: Invalid token - token not found Debug: \r\nError code: invalidtoken\n* line 1155 of \\webservice
      lib.php: moodle_exception thrown\n* line 1049 of \\webservice
      lib.php: call to webservice_server->authenticate_by_token()\n* line 1304 of \\webservice
      lib.php: call to webservice_server->authenticate_user()\n* line 44 of \\webservice\\rest
      server.php: call to webservice_base_server->run()\n

      Show
      Ensure debugging is set to at least MINIMAL. Request the following URL from your Moodle server: /webservice/rest/server.php?wstoken=&wsfunction=fake&moodlewsrestformat=json Expected: No change from before - the JSON result should include a representation of the exception that occurs (it's an invalid token error). Check the web server error log Expected: There should be a new line added to the log, which contains the exception name and stack trace, among other information. The below example is from my local Apache server. [2023-03-30 14:41:00.622915 GMT] [php:notice] [pid 6564:tid 1216] [client 127.0.0.1:50599] REST exception handler: Invalid token - token not found Debug: \r\nError code: invalidtoken\n* line 1155 of \\webservice lib.php: moodle_exception thrown\n* line 1049 of \\webservice lib.php: call to webservice_server->authenticate_by_token()\n* line 1304 of \\webservice lib.php: call to webservice_server->authenticate_user()\n* line 44 of \\webservice\\rest server.php: call to webservice_base_server->run()\n

      When a normal page request throws an uncaught exception, this is stored in the web server error log, providing debugging is set to at least DEBUG_MINIMAL. (See lib/setuplib.php function default_exception_handler.)

      When a REST web service request throws an uncaught exception, this is returned to the caller in JSON or XML format, but is not stored in the web server error log.

      This makes it difficult to detect or debug problems involving the mobile app, for example (users of the app who get the error will see a popup, but we don't have any way at the server end of seeing the stack trace, or of counting how often the problem is happening).

      I think REST web service requests should have similar behaviour to normal web page requests in this regard, i.e. they should record uncaught exceptions in the server error log. (And also send them to the client, unchanged from current behaviour.)

      Note: It's possible this change should also be applied to the other web service handler (SOAP) but that can be done as a separate issue if somebody wants it

            quen Sam Marshall
            quen Sam Marshall
            Meirza Meirza
            Andrew Lyons Andrew Lyons
            Carlos Escobedo Carlos Escobedo
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 40 minutes
                40m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.