ZABBIX BUGS AND ISSUES

fix api return codes

Details

  • Type: Improvement Improvement
  • Status: Need info Need info
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9.0 (alpha)
  • Fix Version/s: None
  • Component/s: API (A)
  • Labels:
    None
  • Zabbix ID:
    NMR

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
An error was received from the Zabbix server
Error code: -32500
Error message: Application error.
Error data: No groups for host [ test ]

add host host=host dns=test groupids=1
An error was received from the Zabbix server
Error code: -32500
Error message: Application error.
Error data: Unknown ZABBIX internal error [CHost]

Activity

Hide
Artem Suharev added a comment -

Please refer to JSON-RPC2.0 manual, error numbers are predefined. Error data field is for details.

Show
Artem Suharev added a comment - Please refer to JSON-RPC2.0 manual, error numbers are predefined. Error data field is for details.
Hide
richlv added a comment -

so i guess we can't change the error code ?
is there anything to do for this issue ?

Show
richlv added a comment - so i guess we can't change the error code ? is there anything to do for this issue ?
Hide
richlv added a comment -

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

Show
richlv added a comment - 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
Hide
nelsonab added a comment -

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:
1) "The error codes from and including -32768 to -32000 are reserved for pre-defined errors. Any code within this range, but not defined explicitly below is reserved for future use. The error codes are nearly the same as those suggested for XML-RPC at the following url: http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php"

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.

Show
nelsonab added a comment - 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: 1) "The error codes from and including -32768 to -32000 are reserved for pre-defined errors. Any code within this range, but not defined explicitly below is reserved for future use. The error codes are nearly the same as those suggested for XML-RPC at the following url: http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php" 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.
Hide
richlv added a comment -

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

Show
richlv added a comment - 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
Hide
nelsonab added a comment -

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."

Show
nelsonab added a comment - 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."
Hide
nelsonab added a comment -

Any chance of a back port to the 1.8.x series?

Show
nelsonab added a comment - Any chance of a back port to the 1.8.x series?
Hide
Kristoffer Berdal added a comment -

+1 for this!

I think a good start would be to define ranges for different error codes. We have lots to choose from!

Show
Kristoffer Berdal added a comment - +1 for this! I think a good start would be to define ranges for different error codes. We have lots to choose from!

People

  • Assignee:
    Unassigned
    Reporter:
    nelsonab
Vote (1)
Watch (2)

Dates

  • Created:
    Updated: