[ZBX-10049] API drule.update asks for iprange and dcheck Created: 2015 Nov 05 Updated: 2017 Dec 14 Resolved: 2016 Feb 29 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 3.0.0alpha3 |
Fix Version/s: | 3.2.0alpha1 |
Type: | Incident report | Priority: | Minor |
Reporter: | vitalijs.cemeris (Inactive) | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | API, discoveryrule | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Issue Links: |
|
Description |
Reproduce: { "druleid ": "2" } Notice error: IP range cannot be empty. than try drule.update with" { "druleid ": "2", "iprange": "192.168.0.1-254" } Notice error: Cannot save discovery rule without checks. |
Comments |
Comment by vitalijs.cemeris (Inactive) [ 2015 Nov 05 ] |
(1) try: { "druleid ": "2", "iprange": "192.168.0.1-254", "dchecks": {"dcheckid": 2} } Notice: gunarspujats This API request is incorrect, correct request would be: { "druleid": "2", "iprange": "192.168.0.1-254", "dchecks": [ {"dcheckid": 2} ] } gunarspujats RESOLVED in r57397. iivs CLOSED |
Comment by Gunars Pujats (Inactive) [ 2015 Dec 29 ] |
(2)
Removed translation strings:
iivs CLOSED sasha New translation string was added:
REOPENED gunarspujats RESOLVED in r58740, changed directly in trunk. iivs The list matches. Looks correct. |
Comment by Gunars Pujats (Inactive) [ 2015 Dec 29 ] |
RESOLVED in development branch svn://svn.zabbix.com/branches/dev/ZBX-10049 |
Comment by Ivo Kurzemnieks [ 2016 Jan 28 ] |
(3) Before validating range, the ID of drule should be validated first. { "druleid": "99922332999231231999223322991231231299922299912319992229931299922333229993" } gunarspujats RESOLVED in r58084.
REOPENED
No, I can't. Maybe "rudolfs" can, he implemented it in this way in r19332. gunarspujats RESOLVED in r58136. iivs CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Jan 28 ] |
(4) IP range now accepts any string for granted with no validation. { "druleid": "100100000000046", "iprange": "192.168.0.1-2514" } gunarspujats RESOLVED in r58084. iivs The IP validation is poor, but then again it's an old branch. CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Jan 28 ] |
(5) Possible to update without dchecks. { "druleid": "100100000000046", "dchecks": [ ] } gunarspujats RESOLVED in r58084. iivs Since we already changed the behaviour of "dchecks" validation, we might as well fix and old problem that it's possible to add a dcheck like this { "druleid": "100100000000046", "dchecks" : [ { } ] } and guess what type does it have.
It's also possible to save any number in "type" field. REOPENED gunarspujats RESOLVED in r58136. iivs While looking at 2.2 I discovered several bugs. Since we're now fixing this for trunk (see (7)), we could do things properly. Here are the things I found:
Let's see if we can make this work and not repeat same mistakes in trunk. REOPENED gunarspujats RESOLVED in r58414. iivs CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Jan 29 ] |
(6) Coding style:
gunarspujats Created separate functions validateCreate() and validateUpdate(). RESOLVED in r58235. iivs The validation for field "name" has changed slightly. It's still possible to get same error when setting it to null. Error says "Discovery rule "" already exists." Both create() and update() methods are affected. Also a bit older bug, but it's possible to set type to null. Instead of in_array() we tend to use SetValidator() to avoid such problems. REOPENED gunarspujats RESOLVED in r58417.
Please revert all changes regarding schema validator, they are just horrible. REOPENED gunarspujats RESOLVED in r58593.
REOPENED gunarspujats RESOLVED in r58723. iivs CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Feb 05 ] |
(7) I moved the code in r58282 to better location so that it's easier to see the final changes with diff. And looking at the changes they seem to grow quite a bit. I mean a lot. Discussed with sasha and decided to fix this only for trunk (and not for 3.0.0, but later for 3.1.0). Please move this and changes to new development branch. The exists() method is removed for trunk, so be careful when copy pasting code to new development branch. Also in trunk the duplicate name is checked after checkInput(), you might want to look into that too. gunarspujats RESOLVED in r58346. iivs API has a poor consistency when it comes to missing parameters. Enter one parameter and it turns out another one is missing. Enter another one and again it turns out that more are missing. That's why it would be better to show what parameters are missing from the beginning. Take ValueMap API, for example, and see a list of missing parameters separated by comma. Few other APIs has this implemented as well. This is the direction we should aim. First check for all missing keys. Otherwise, we could enter API::DRule()->create(['']); and receive many more unnecessary errors. And also in that case we could avoid unreasonable errors like Also please notice that the order of validation is off. I have a existing drule. Only after I entered "name", "iprange" and "dchecks" it validated name, but when I entered a different name, it continues to validate "dchecks" parameter. Check the name first for all duplicates, existing names. After that continue validating other parameters. Similarly with "proxy_hostid" parameter. It checks it once, then checks name for duplicates and then checks ID again. And in the end it gives two different error messages. Please revert all changes regarding schema validator, they are just horrible. REOPENED gunarspujats RESOLVED in r58591. iivs CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Feb 16 ] |
(8) drule.update: [ { "druleid": 31, "name": "a" }, { "druleid": 30, "name": "b" }, { "druleid": 31, "name": "c" } ]
gunarspujats RESOLVED in r58591.
REOPENED gunarspujats RESOLVED in r58704.
REOPENED gunarspujats RESOLVED in r58723. iivs I find this construction elseif (!is_string($drule['druleid']) && !is_int($drule['druleid']) || !zbx_is_int($drule['druleid'])) { self::exception(ZBX_API_ERROR_PARAMETERS, _s('Field "%1$s" is not integer.', 'druleid')); } terrible. gunarspujats CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Feb 16 ] |
(9) drule.update: { "druleid": "25" } updates drule and clears dchecks. gunarspujats RESOLVED in r58591. iivs CLOSED |
Comment by Ivo Kurzemnieks [ 2016 Feb 23 ] |
(10) drule.update: gunarspujats RESOLVED in r58699. iivs CLOSED |
Comment by Gunars Pujats (Inactive) [ 2016 Feb 26 ] |
Fixed in:
|
Comment by Gunars Pujats (Inactive) [ 2016 Feb 26 ] |
(11) Documentation: iivs I sligtly changed the sentence, so there are no same words repeating. Please, review. gunarspujats CLOSED |
Comment by Ivan [ 2017 Dec 08 ] |
Fix Version/s: |