API User.update has poor error reporting... reports "Application error" when something fails

XMLWordPrintable

    • Type: Incident report
    • Resolution: Won't fix
    • Priority: Major
    • None
    • Affects Version/s: 1.8
    • Component/s: API (A)

      For the API method user.update, when you pass in invalid data, for example attempting to update a user_id that doesn't exist, it returns very generic non-specific errors...

      For example if I hit the Zabbix API with the following...

      ZabbixAPI::user.update (
      'userid'=>5, //Note this userid doesn't exist
      'refresh'=>1000,
      );

      It returns...

      Array (
      [code] => -32500
      [message] => Application error.
      [data] => [ CUser::update ] Error in query [UPDATE users SET name='', surname='', alias='', passwd='', url='', autologin=, autologout=, lang='', theme='', refresh=1000, rows_per_page=, type= WHERE userid=5] [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' autologout=, lang='', theme='', refresh=1000, rows_per_page=, type= WHERE' at line 1]
      )

      It would be ideal if message was at least something relevant, but keeping the [data] field verbose is good I think to help you guys clearly diagnose the problem.

      Array (
      [code] => -12345
      [message] => Invalid userid, unable to update record
      [data] => [ CUser::update ] Error in query [UPDATE users SET name='', surname='', alias='', passwd='', url='', autologin=, autologout=, lang='', theme='', refresh=1000, rows_per_page=, type= WHERE userid=5] [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' autologout=, lang='', theme='', refresh=1000, rows_per_page=, type= WHERE' at line 1]
      )

      Cheers!

            Assignee:
            Unassigned
            Reporter:
            Andrew Farley
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: