-
Patch request
-
Resolution: Duplicate
-
Minor
-
None
-
3.0.28
-
None
-
Go lang 1.12.1, json_rpc api
Steps to reproduce:
- 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
- duplicates
-
ZBX-12943 Host API inconsistency for inventory_mode attribute
- Closed