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

Configuration Export api call returns not consistent

XMLWordPrintable

    • Icon: Patch request Patch request
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.0.28
    • API (A)
    • None
    • Go lang 1.12.1, json_rpc api

      Steps to reproduce:

      1. make `configuration.export` call to host with disabled inventory 

      Result:
      Json blob that looks like the following:

      zabbix_export: {
      ...
      macros: [],
      inventory: [],
      ...
      }

       

      Expected:

      zabbix_export: {
      ...
      macros: [],
      inventory: {}, 
      ...
      }

       

      The main issue here is when an inventory is returned it is expected to just be a map of string:value. Though when it is disabled it just returns an empty array which is a totally different type than when an inventory is found. So if you are preforming a bulk operation on hosts that could/couldnt have inventory setup you cannot load it into a struct similar to below even if you are omitting the empty field because the types are different :

      type Host struct {
         Host string `json:"host"`
         Name string `json:"name"`
         Description string `json:"description,omitempty"`
         Inventory Inventory `json:"inventory,omitempty"`
      }
      
      type Inventory struct {
         Name string `json:"name,omitempty"`
      }
      

      The error you receive when trying to load host with inventory disabled:

      json: cannot unmarshal array into Go struct field Host.inventory of type v1.Inventory
      

            zabbix.support Zabbix Support Team
            frenchtoasters Tyler French
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: