[ZBX-6613] Incorrect error message when creating a trigger prototype Created: 2013 May 20  Updated: 2017 May 30  Resolved: 2013 Jun 04

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Frontend (F)
Affects Version/s: 2.0.6, 2.1.0
Fix Version/s: 2.1.0

Type: Incident report Priority: Minor
Reporter: Pavels Jelisejevs (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: api, frontend, triggerprototypes
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

If you try to create a trigger prototype without an item prototype, you will see the following message:

Created: Trigger prototype "trigger" on "trapper-host 2".
Trigger "trigger:

{13109}

=0" does not have item prototype. [trigger_prototypes.php:166 ? CAPIObject->create() ? CAPIObject->__call() ? czbxrpc::call() ? czbxrpc::callAPI() ? call_user_func() ? CTriggerPrototype->create() ? CZBXAPI::exception() in /opt/lampp/htdocs/zabbix/trunk/frontends/php/api/classes/CTriggerPrototype.php:523]

There are several problems with it:
1. It says that the prototype was created, even when it wasn't.
2. The expression in the error message is imploded.
3. The error message is grammatically incorrect. It should be changed to something like "Trigger prototype expression %expression% must contain at least one item prototype."



 Comments   
Comment by Eduards Samersovs (Inactive) [ 2013 May 23 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-6613

Comment by Oleg Egorov (Inactive) [ 2013 May 23 ]

(1) Coding style
Lines in triggers.inc.php:1017 and in CTriggerPrototype.php:524 is too long

Unnecessary tabs in triggers.inc.php:1028, CTriggerPrototype.php:524 and in CTriggerPrototype.php:629

Eduards RESOLVED r.35810

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2013 May 23 ]

(2) Unnecesary code in triggers.inc.php:1005

$triggerFunctionValidator = new CTriggerFunctionValidator();

Defined, but not used...

Eduards RESOLVED r.35810

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2013 May 23 ]

(3) Please fix same problem when updating a trigger prototype

Eduards RESOLVED r.35810

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2013 May 23 ]

(4)
Incorrect item key "agent.ping" provided for trigger expression on "DONTEXIST". [trigger_prototypes.php:161 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CTriggerPrototype->update() → getExpressionItems() in C:\xampp\htdocs\ZBX-6613\frontends\php\api\classes\CTriggerPrototype.php:614]

Host "DONTEXIST" - don't exist

Incorrect message after trigger prototype updating

Eduards RESOLVED r.35817

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2013 May 23 ]

(5) Function "getExpressionItems" SELECT inside foreach loop... should be discussed

Eduards Discussed and decided not to do.

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2013 May 24 ]

TESTED

Comment by Eduards Samersovs (Inactive) [ 2013 May 24 ]

Fixed in versions pre-2.1.0 (beta) r.35820

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(6) In CTriggerPrototype line 500 you've changed array_key_exists to isset. This is incorrect, because a create request with templateid=>null must also raise an error.

Eduards RESOLVED r.35861

jelisejev CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(7) In triggers.inc.php getExpressionItems() line

if (!isset($processedItems[$expression['host'].$expression['item']])) {

Don't use concatenated keys for such checks as there might be two different host-item pairs that produce the same concatenated strings. Then the function will work incorrectly. Use a 2D array instead.

Eduards RESOLVED r.35861

jelisejev CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(8) In CTriggerPrototype line 534: there's no need to fetch $createdTriggers.

Eduards RESOLVED r.35861

jelisejev CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(9) The following request fails with an error: Incorrect trigger expression.

{
    "jsonrpc": "2.0",
    "method": "triggerprototype.update",
    "params": {
        "triggerid": 13611,
        "status": 0
    },
    "id": 3,
    "auth": "7ad89cb5537b8d4127d1c283097528db"
}

Eduards RESOLVED r.35861

jelisejev CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(10) In CTriggerPrototype::create() the expression is parsed twice. Once in the create() method, and a second time in getExpressionItems().

Eduards RESOLVED r.35861

jelisejev It would be better to pass not the separate expressions, but the whole CTriggerExpression object to getExpressionItems(). That way the parameter will be clearer.

Eduards RESOLVED r.35877

jelisejev Please review my changes in r35902.

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

(11) The getExpressionItems() function shouldn't throw the "Incorrect trigger expression part "%1$s".". This is done in the implode_exp() function.

Eduards RESOLVED r.35861

jelisejev CLOSED.

Comment by Eduards Samersovs (Inactive) [ 2013 May 27 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-6613

Comment by Pavels Jelisejevs (Inactive) [ 2013 May 27 ]

Please review my changes in (10). Otherwise TESTED.

Comment by Eduards Samersovs (Inactive) [ 2013 May 28 ]

Fixed in versions pre-2.1.0 (beta) r.35905

Comment by Egita Sidorova (Inactive) [ 2013 Jun 03 ]

failing tests on POSTGRESQL
error message appears when saving hosts

selecting host in configuration of hosts, click 'save'
error message appears

pg_query(): Query failed: ERROR: column "i.hostid" must appear in the GROUP BY clause or be used in an aggregate function [hosts.php:470 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CHost->update() → CHost->massUpdate() → CHost->massAdd() → CHostGeneral->massAdd() → CHostGeneral->link() → DBselect() → pg_query() in /home/hudson/public_html/trunk-FRONTEND-POSTGRESQL/frontends/php/include/db.inc.php:441]

Error in query [SELECT i.key_,i.hostid FROM items i WHERE i.hostid IN ('10047','10001','10001','10047') GROUP BY i.key_ HAVING COUNT(i.itemid)>1] [ERROR: column "i.hostid" must appear in the GROUP BY clause or be used in an aggregate function]

Eduards RESOLVED r.36052

oleg.egorov CLOSED

Comment by Oleg Egorov (Inactive) [ 2013 Jun 04 ]

TESTED

Comment by Eduards Samersovs (Inactive) [ 2013 Jun 04 ]

Fixed in versions pre-2.1.0 (beta) r.36056

Generated at Sat Apr 20 02:25:47 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.