[ZBX-5565] API returns HTML page when the database is down, instead of returning an appropriate error response. Created: 2012 Sep 10  Updated: 2017 May 30  Resolved: 2012 Oct 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 2.0.2
Fix Version/s: 2.1.0

Type: Incident report Priority: Major
Reporter: Kristoffer Berdal Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: api, json, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Does it matter? Centos



 Description   

The webpage that is shown to the user when zabbix is unable to connect to the database is also returned when you make a call to the API while the database is down.

This causes problems as instead of getting JSON you are suddenly getting HTML to parse.

This is the text on the website:

pg_connect() [<a href='function.pg-connect'>function.pg-connect</a>]: Unable to connect to PostgreSQL server: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 5432? [include/db.inc.php:99]
Constant ZBX_PAGE_NO_MENU already defined [warning.php:29]
Zabbix 2.0.2

Zabbix is temporarily unavailable!

This is not good. The API should return an error that can easily be parsed, just like the rest of them. Preferrably it would be best if the API started defining its own error codes as the JSONRPC v2 standard says you should.

http://www.jsonrpc.org/specification#error_object

I do not know if this is fixed in a later version, but I noticed the problem when I suddenly got an error in the simple API client I have created for node.js https://github.com/flexd/zabbix.js

Getting HTML when you expect to parse JSON and no errors were returned is not good



 Comments   
Comment by Oleksii Zagorskyi [ 2012 Sep 24 ]

the "warning.php:29" error also mentioned in ZBX-5603

Comment by Kristoffer Berdal [ 2012 Sep 24 ]

That is unrelated to the problem here. The problem is that it should not be showing the error HTML page in the first place!

Comment by Alexey Fukalov [ 2012 Oct 11 ]

dev branch: svn://svn.zabbix.com/branches/dev/ZBX-5565

Comment by Eduards Samersovs (Inactive) [ 2012 Oct 17 ]

(1) without zabbix.conf.php Frontend doesn't work
Fatal error: Call to undefined function DBid2nodeid() in /home/zabbix/www/testing-ZBX-5565/frontends/php/include/nodes.inc.php on line 74

Similar fatal error if we open http://localhost/warning.php

Vedmak RESOLVED
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Oct 17 ]

(2) Offer to use CWarning class in warning.php

Vedmak RESOLVED
Eduards please init $warningMessage var as global if it is global and insert license copyright into /include/warning.php

Vedmak RESOLVED
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2012 Oct 19 ]

Tested!

Comment by Alexey Fukalov [ 2012 Oct 19 ]

Fixed in pre-2.1.0 r30948.

Comment by Pavels Jelisejevs (Inactive) [ 2012 Oct 19 ]

(3) Please note this in the API changelog under the general section.

Vedmak CLOSED

Comment by Alexander Vladishev [ 2012 Oct 19 ]

(5) Errors on all pages like:

Warning: array_map() [function.array-map]: The first argument, 'stripslashes_deep', should be either NULL or a valid callback in include/defines.inc.php on line 927

Warning: array_map() [function.array-map]: The first argument, 'stripslashes_deep', should be either NULL or a valid callback in include/defines.inc.php on line 927

Warning: array_map() [function.array-map]: The first argument, 'stripslashes_deep', should be either NULL or a valid callback in include/defines.inc.php on line 927

Cannot modify header information - headers already sent by (output started at include/defines.inc.php:927) [func.inc.php:70]
Cannot use a scalar value as an array [page_header.php:28]
Cannot modify header information - headers already sent by (output started at include/defines.inc.php:927) [page_header.php:105]

Vedmak RESOLVED

sasha CLOSED

Comment by Kristoffer Berdal [ 2012 Oct 22 ]

What's going on with this? I saw it was closed and fixed a long time ago. Why the bloody hell am I getting like 20 messages of email spam per day about this?

Comment by richlv [ 2012 Oct 22 ]

the fix is being polished and improved. developers do work on it. as it's all opensource, you get to follow all the development process.

Comment by Oleksii Zagorskyi [ 2012 Oct 22 ]

Kristoffer, you are issue reporter, that's why you are receiving notifications.
Not so many issues have such intensive "work flow", so do not worry to report other issues

Comment by Alexey Fukalov [ 2012 Oct 22 ]

Fixed in pre-2.1.0 r31014.

Comment by richlv [ 2013 Jan 08 ]

this resulted in a regression : ZBX-6073

Comment by richlv [ 2013 Sep 30 ]

this resulted in another regression : ZBX-7066

Generated at Mon Apr 28 09:54:13 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.