Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-16615

Inappropriate error message if an incorrectly passed API parameter has only one possible value

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 4.4.0alpha2
    • API (A)

      Problem description: If an API parameter has only 1 possible valid value, and it is passed with an incorrect value, the error message refers to its possible values in plural, even though only 1 possible option is mentioned in it. For example, the error message obtained when specifying an incorrect value of "output" parameter of autoregistration.get API: "Invalid parameter \"/output\": value must be one of extend."
      Furthermore, other get APIs don't have any validation for this parameter at all.

      Steps to reproduce:
      Send the following API:

      {
         "jsonrpc": "2.0",
          "method": "autoregistration.get",
          "params": {
              "output": "incorrect_value"
          },
          "auth": "e5fef1c5302e22e4d4b56bafd621ac93",
          "id": 1
      }
      

      Result:

      "error": {
              "code": -32602,
              "message": "Invalid params.",
              "data": "Invalid parameter \"/output\": value must be one of extend."
      

      Expected:
      "data": "Invalid parameter \"/output\": value must be equal to 'extend'."

      Send any other get API with incorrect value of "output" parameter:

      {
          "jsonrpc": "2.0",
          "method": "host.get",
          "params": {
              "output": "please_do_not_extend"
          },
          "auth": "e5fef1c5302e22e4d4b56bafd621ac93",
          "id": 1
      }
      

      Result: a list of the referred entities ids is returned:

      {
          "jsonrpc": "2.0",
          "result": [
              {
                  "hostid": "10084"
              },
              {
                  "hostid": "10264"
              }
          ],
          "id": 1
      }
      

      Expected: an error stating that the passed 'extend' parameter value is incorrect should be returned, like in the case of autoregistration.get API.

            zabbix.dev Zabbix Development Team
            solonkins Sergejs Olonkins
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: