[ZBX-5648] Zabbix API item.update doesn't update item 'name' parameter. Created: 2012 Oct 03 Updated: 2017 May 30 Resolved: 2012 Oct 17 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 2.0.2, 2.0.4rc1, 2.1.0 |
Fix Version/s: | 2.0.4rc1, 2.1.0 |
Type: | Incident report | Priority: | Major |
Reporter: | Alexander Malaev | Assignee: | Oleg Egorov (Inactive) |
Resolution: | Fixed | Votes: | 0 |
Labels: | api | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
Hi! I tried to update Item params with item.update method of zabbix api, all params has changed succesfully, but 'name' field hasn't updated. 10: json_obj: {'params': {'itemid': u'30917', 'key_': 'failcounter[parts5.time_median]', 'name': 'Failcounter: \xd0\xa1\xd1\x82\xd0\xb0\xd1\x82. \xd1\x81\xd1\x80\xd0\xb5\xd0\xb4. \xd0\xb2\xd1\x80\xd0\xb5\xd0\xbc\xd1\x8f \xd0\xbe\xd1\x82\xd0\xb2\xd0\xb5\xd1\x82\xd0\xb0 \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb5\xd0\xba\xd1\x82\xd0\xb0 parts5', 'description': 'Failcounter: \xd0\xa1\xd1\x82\xd0\xb0\xd1\x82. \xd1\x81\xd1\x80\xd0\xb5\xd0\xb4. \xd0\xb2\xd1\x80\xd0\xb5\xd0\xbc\xd1\x8f \xd0\xbe\xd1\x82\xd0\xb2\xd0\xb5\xd1\x82\xd0\xb0 \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb5\xd0\xba\xd1\x82\xd0\xb0 parts5', 'delay': 300, 'trends': 30, 'value_type': 0, 'templateid': u'10307', 'type': 0, 'history': 14}, 'jsonrpc': '2.0', 'method': 'item.update', 'auth': u'2dcaf3d694a7aea4c656549728c6009e', 'id': 217} 20: Sending: {"params": {"itemid": "30917", "key_": "failcounter[parts5.time_median]", "name": "Failcounter: \u0421\u0442\u0430\u0442. \u0441\u0440\u0435\u0434. \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 parts5", "description": "Failcounter: \u0421\u0442\u0430\u0442. \u0441\u0440\u0435\u0434. \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 parts5", "delay": 300, "trends": 30, "value_type": 0, "templateid": "10307", "type": 0, "history": 14}, "jsonrpc": "2.0", "method": "item.update", "auth": "2dcaf3d694a7aea4c656549728c6009e", "id": 217} 10: Sending headers: {'Content-Type': 'application/json-rpc', 'User-Agent': 'python/zabbix_api'} 20: Response Code: 200 10: Response Body: {u'jsonrpc': u'2.0', u'result': {u'itemids': [u'30917']}, u'id': 217} I'm using python api for making requests. Item 'failcounter[parts5.time_median]' is templated item, and it belongs to template 'Template_App_failcounter". |
Comments |
Comment by Oleg Egorov (Inactive) [ 2012 Oct 04 ] |
RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-5648 r30619 |
Comment by Toms (Inactive) [ 2012 Oct 05 ] |
(1) This check should be performed in CItemGeneral::CheckInput(), to support check for discovery items, and item prototypes oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-5648 r30680 tomtom CLOSED. Review my changes in r30688, if OK merge. |
Comment by Toms (Inactive) [ 2012 Oct 08 ] |
TESTED |
Comment by Oleg Egorov (Inactive) [ 2012 Oct 08 ] |
Fixed in 2.0.4 r30708, 2.1.0 r30709 |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 09 ] |
(1) This fix must be documented in the 2.0 API changelog. oleg.egorov RESOLVED jelisejev CLOSED. jelisejev Don't forget to document the remaining fixes when you're done. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 09 ] |
(2) The same check should be performed for graphs, triggers, screens (both templated and plain) and all of the prototypes. oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-5648-2 r30786 jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 11 ] |
(3) You've added a $prototype parameter to the CGraphGeneral::checkInput() method. It's not the best solution, if you need some specific validation rules for either prototypes or graphs, just extend this method in the corresponding class. Please, pay extra attention to the check on line 146: it looks weird to me. oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-5648-2 r30798 jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 11 ] |
(4) Don't use isset() to check the "templateid" property, because it will pass through NULLs. Use array_key_exists() instead. oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-5648-2 r30798 jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 11 ] |
(5) A similar check has to be performed for template screens. There's a difference, though. In template screens, the "templateid" field refers to the template that the screen belongs to, not to the parent screen. So the "templateid" property must be set when calling create, but cannot be changed later. oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-5648-2 r30801 jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 11 ] |
(6) Since your fix affected the screen validation, may be you could also implement the correct validate methods for update and delete? See CService as an example. Keep in mind, that CTemplateScreen extends CScreen and already has some validation methods, maybe they can be unified. oleg.egorov RESOLVED IN svn://svn.zabbix.com/branches/dev/ZBX-5648-2 r30801 jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(7) There's an error on the template configuration page. Declaration of CTemplateScreen::validateCreate() should be compatible with that of CScreen::validateCreate() [api/classes/CTemplateScreen.php:25] Make sure you have strict standard errors enabled. oleg.egorov RESOLVED jelisejev We always use type hinting for arrays, so instead of removing it, you need to add it where it's missing. oleg.egorov RESOLVED jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(8) I cannot create a plain screen: Cannot set "templateid" for screen. [CScreen.create -> CScreen.validateCreate] oleg.egorov RESOLVED jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(9) Some issues regarding screens: 1. In CScreen::validateCreate() we first need to check if the fields are correct, only then - if the screen doesn't exist. oleg.egorov RESOLVED jelisejev Please review my changes in r30877. If everything is OK, it can be closed. oleg.egorov CLOSED |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(10) In CTemplateScreen::validateUpdate(): 1. templateid must be validated after permissions; oleg.egorov RESOLVED jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(11) Some error message improvements: 1. When calling update methods, the error should read "Cannot update" instead of "Cannot set"; So, for create methods it should be: "Cannot set "templateid" for screen "%1$s". Keep in mind, that the name of the screen may not be passed to update methods, so you may have to pull it out of the database using the CZBXAPI::extendObjects() methods or in some other way. oleg.egorov RESOLVED jelisejev CLOSED. |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(12) In CTrigger::checkInput() templateid check must be performed before the permission check. oleg.egorov RESOLVED jelisejev Please review my changes in r30879. oleg.egorov CLOSED |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(13) In CGraph::checkInput(): 1. Permissions need to be validated before calling parent::checkInput(). Don't forget, that before checking permissions you need to check that items and item IDs are valid. oleg.egorov RESOLVED jelisejev Before using items IDs to validate permissions, we need to validate the items and item IDs themselves. That is, the check in CGraphGeneral::checkInput() lines 66 and 73 have to be performed before permission checks. Also please review my changes in r30879. oleg.egorov RESOLVED jelisejev itemids also needed to be validated. Please review my changes in r30894. oleg.egorov OK, CLOSED |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 12 ] |
(14) In CGraphPrototype::checkInput(): 1. Permissions need to be validated before calling parent::checkInput(). Don't forget, that before checking permissions you need to check that items and item IDs are valid. oleg.egorov Duplicated in (13) jelisejev Sorry, I meant CGraphPrototype. oleg.egorov RESOLVED jelisejev Same problem as in (13). oleg.egorov RESOLVED jelisejev CLOSED. |
Comment by Alexander Vladishev [ 2012 Oct 15 ] |
(15) Cannot Full clone a template: "Cannot set "templateid" for item." oleg.egorov RESOLVED jelisejev Please review my changes in r30904. oleg.egorov CLOSED |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 15 ] |
(16) Almost forgot: this also has to be done for applications. oleg.egorov RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-5648-2 r30863 jelisejev Please review my changes in r30884. oleg.egorov CLOSED |
Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 17 ] |
(17) Cannot create a graph prototype: Undefined variable: allowedItems [api/classes/CGraphPrototype.php:890] oleg.egorov This error not exist in my last revision RESOLVED jelisejev CLOSED. |
Comment by Oleg Egorov (Inactive) [ 2012 Oct 17 ] |
FIXED IN 2.0.4rc1 r30905, 2.1.0 (trunk) r30908 |