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

JSONPath takes into account absent fields when doing math compare operations (<, > and so on)

    XMLWordPrintable

Details

    • Incident report
    • Status: Confirmed
    • Trivial
    • Resolution: Unresolved
    • 5.0.7
    • None
    • Server (S)
    • None
    • debian 10, postgres, nginx

    Description

      Steps to reproduce:
      JSONPath erroneously takes into account absent fields when doing math compare operations (<, > and so on).
      Let's take an example from documentation with one book without a price:

      {
        "books": [
          {
            "author": "Nigel Rees",
            "title": "Sayings of the Century",
            "price": 8.95,
            "id": 1
          },
          {
            "author": "Evelyn Waugh",
            "title": "Sword of Honour",
            "price": 12.99,
            "id": 2
          },
          {
            "author": "Herman Melville",
            "title": "Moby Dick",
            "isbn": "0-553-21311-3",
      
            "id": 3
          }]
      }
      

      If we make a condition with a price less than 10, it grabs a result with a book also with absent field 'price':
      $.books[?(@.price <10)]

      [{
      "author": "Nigel Rees",
      "title": "Sayings of the Century",
      "price": 8.95,
      "id": 1
      },{
      "author": "Herman Melville",
      "title": "Moby Dick",
      "isbn": "0-553-21311-3",
      
      "id": 3
      }]
      

      Instead it should ignore a book without that field and should show only one book.

      Attachments

        Activity

          People

            zabbix.dev Zabbix Development Team
            darkblaze69 darkblaze69
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: