[ZBX-5770] SQL query failed after host.create with two groups with the same ID Created: 2012 Oct 30  Updated: 2019 Aug 28  Resolved: 2019 Aug 28

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 2.0.3
Fix Version/s: None

Type: Incident report Priority: Minor
Reporter: matthieu Assignee: Unassigned
Resolution: Won't fix Votes: 0
Labels: api, sql, validation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix server 2.0.3
Debian 6.0
Apache 2
MySQL server 5.1.49-3



 Description   

When using the API to create a host (host.create), if the user (or the script) specify two times the same hostgroup ID the query fails:

zabbix_api.ZabbixAPIException: (u'Error -32500: Application error., SQL statement execution has failed "INSERT INTO hosts_groups (hostid,groupid,hostgroupid) VALUES (\'12221\',\'57\',\'6927\')". while sending {"params": {"proxy_hostid": "10085", "name": "SXXXXXXXXXXXI", "interfaces": [{"ip": "10.XXX.XX.1", "useip": 1, "dns": "", "main": 1, "type": 2, "port": "161"}], "host": "SXXXXXXXXXX1", "inventory": {"location_lat": "X.XXXXX", "site_address_c": "3", "site_address_b": "2", "site_address_a": "XXXXXXXXX", "location_lon": "XXXXXXXX", "location": "XXXXXXXXXX"}, "groups": [{"groupid": "6"}, {"groupid": "43"}, {"groupid": "57"}, {"groupid": "405"}, {"groupid": "57"}, {"groupid": "10"}]}, "jsonrpc": "2.0", "method": "host.create", "auth": "1e47807fe04b2c57690701aba3e58b60", "id": 7}', -32500)

We can see that the JSON array contains two times the groupid '57'.

I know this query is not well formed, but it should not failed.
Ideally it should only add the host in the hostgroup one time.



 Comments   
Comment by richlv [ 2012 Oct 30 ]

what's the error message ? do you get sql errors ?

actually, it should fail - but the response should be proper api response. if it's not, that should be fixed, of course

Comment by matthieu [ 2012 Oct 30 ]

The error returned by the API is what I have posted above.

It is not a proper API response because the API is trying to insert 2 times the group in the table hosts_groups.
I was expecting the API to say "Hey there is a duplicate hostgroup in your query" in zabbix vocabulary of course .

Comment by richlv [ 2012 Oct 30 ]

bah. i glanced over the sql part, sorry

Comment by Vladislavs Boborikins (Inactive) [ 2019 Aug 28 ]

Hello,

Since this version of Zabbix is no longer supported, we've decided not to prioritize this bug for the near future and close the issue with "Won't fix" resolution.

Please let us know if this decision should be reconsidered.

Regards
Vladislavs

Generated at Sun Aug 03 03:40:42 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.