[ZBX-1125] fix api return codes Created: 2009 Oct 21 Updated: 2017 Oct 24 Resolved: 2017 Oct 24 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | API (A) |
Affects Version/s: | 1.9.0 (alpha) |
Fix Version/s: | None |
Type: | Incident report | Priority: | Major |
Reporter: | nelsonab | Assignee: | Unassigned |
Resolution: | Unsupported version | Votes: | 3 |
Labels: | api, returncode | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
Error messages should have their own differing error number. The error number is an excellent way for programs that use the API to determine what the error is. The following is an example of two errors that both have the same error number but different error messages. add host host=test dns=test add host host=host dns=test groupids=1 |
Comments |
Comment by Artem Suharev (Inactive) [ 2009 Oct 29 ] |
Please refer to JSON-RPC2.0 manual, error numbers are predefined. Error data field is for details. |
Comment by richlv [ 2011 Apr 05 ] |
so i guess we can't change the error code ? |
Comment by richlv [ 2011 Apr 05 ] |
hmm. would be useful to list all error codes returned by zabbix api at this point in the api docs - even if that would partially duplicate json-rpc spec or whatever |
Comment by nelsonab [ 2011 Apr 08 ] |
Upon reading the JSON RPC 2.0 specification it is in fact possible for the application developer to define their own error codes. http://groups.google.com/group/json-rpc/web/json-rpc-2-0 Section 5.1 has the following two key statements: 2) "The remainder of the space is available for application defined errors." Thus all error codes outside the range of -32,000 -> -32,768 are available for the end application, such as Zabbix. |
Comment by richlv [ 2011 Apr 24 ] |
this seems to be fairly important to make api messages reasonably parse-able - although a spec should be created before implementing anything, detailing decided upon return codes and guidelines/rules for assigning new ones |
Comment by nelsonab [ 2011 Apr 24 ] |
Agreed! Let's create a page on Zabbix.org and start filling out the error code table. Also if one of us is feeling very "adventurous" we may even start submitting some patches for this. If this can make it into Zabbix 2.0 then the API can be one step closer to "winning." |
Comment by nelsonab [ 2011 Aug 04 ] |
Any chance of a back port to the 1.8.x series? |
Comment by Kristoffer Berdal [ 2012 Jul 26 ] |
+1 for this! I think a good start would be to define ranges for different error codes. We have lots to choose from! |
Comment by richlv [ 2016 Jun 11 ] |
reportedly in case of invalid auth the error code could now be -32602 - but that does not seem to be documented anywhere, so probably best not to rely on it anyway |
Comment by Rostislav Palivoda [ 2017 Oct 24 ] |
Please reopen if required. |