-
Problem report
-
Resolution: Won't fix
-
Trivial
-
None
-
5.0.11
-
PHP 7.2.24
nginx/1.16.1
Zabbix frontend: 5.0.11
Steps to reproduce:
- Add new host via the API, the request must contain template IDs, for example:
host=testhost,
status=0,
groups=[\{'groupid': 18}, \{'groupid': 20}, \{'groupid': 143}],
interfaces=...,
proxy_hostid='10123',
templates=['12345']
Result:
Response from the Frontend:
{{{}}
{{'code': -32500, }}
{{'message': 'Application error.', }}
{{'data': 'No permissions to referred object or it does not exist!', }}
'debug': [
{{{}}
{{'file': '/usr/share/zabbix/include/classes/api/services/CHostBase.php', 'line': 49, }}
{{'function': 'exception', }}
{{'class': 'CApiService', }}
{{'type': '::', }}
'args': [120, 'No permissions to referred object or it does not exist!']}
In the nginx logs:
2021/06/02 14:35:59 [error] 21#0: *619655 FastCGI sent in stderr: "PHP message: PHP Warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: ""
LINE 1: ...(r.permission)>0 AND MAX(r.permission)>='2') AND h.hostid=''
{{ ^ in /usr/share/zabbix/include/db.inc.php on line 247" while reading response header from upstream, client: X.X.X.X, server: zabbix, request: "POST /api_jsonrpc.php HTTP/1.1", upstream: "fastcgi://unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock:", host: "zabbix"}}
{{ Expected:}}
}}{{
It should add the host with the linked templates.
When I remove the "templates" field from the request, and I add the templates in a separate request, when the host already exists, it's working fine.