[MXS-4657] Add human readable message text to API errors like 404 Created: 2023-06-27  Updated: 2023-07-27  Resolved: 2023-07-13

Status: Closed
Project: MariaDB MaxScale
Component/s: REST-API
Affects Version/s: None
Fix Version/s: 2.5.27, 6.4.8, 22.08.7, 23.02.3, 23.08.0

Type: Bug Priority: Major
Reporter: Hartmut Holzgraefe Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None


 Description   

We had a customer mis-reading the switchover command documentation, putting the actual monitor section name too early in the command. Also they were using galeramon, so a switchover command does not exist in that monitor anyway.

They got a "404 not found" in both cases without any further info, and so were lost.

Looking at raw TCP traffic with Wireshark I'm seeing that there is indeed no additional content in the maxscale API reply providing further info, just a HTTP header with the 404 status, and some default header fields, e.g. maxctrl sent:

GET /v1/maxscale/modules/galeramon/switchover?myMonitor&galera-node-1&galera-node-2 HTTP/1.1
Accept: application/json, text/plain, */*
User-Agent: axios/0.21.4
Host: 127.0.0.1:8989
Authorization: Basic YWRtaW46bWFyaWFkYg==
Connection: close

which failed as "galeramon" does not implement "switchover", only "mariadbmon" does. All that came back was:

HTTP/1.1 404 Not Found
Connection: close
Content-Length: 0
Cache-Control: no-cache
Referrer-Policy: same-origin
X-XSS-Protection: 1
X-Frame-Options: Deny
Date: Tue, 27 Jun 23 14:09:56 GMT
Last-Modified: Tue, 27 Jun 2023 14:07:18 GMT
ETag: "da39a3ee5e6b4b0d3255bfef95601890afd80709"

IMHO this should definitely have an extra content section containing e.g.

"Module 'galeramon' has no command 'switchover'"

Also at first the customer used

call command Galera-Monitor switchover RHEL8-Galera-2 RHEL8-Galera-1

instead of

call command galeramon switchover Galera-Monitor RHEL8-Galera-2 RHEL8-Galera-1

so here they should have gotten something like

"No such module "Galera-Monitor", available modules are 'mariadbmon', 'galeramon', 'xpandmon' ..."

back there to help them finding the wrong command syntax used.

Whether the feedback is returned as simple plain text message, or embedded in a JSON document, I don't care either way. But some feedback beyond "something's wrong" is definitely needed



 Comments   
Comment by markus makela [ 2023-06-27 ]

I'll convert this into a bug since nothing prevents a human-readable error from being returned and (IMO) it should've always have done that.

Comment by markus makela [ 2023-06-28 ]

For 2.5 the maxctrl error message can be amended to indicate that a 404 always means that the object does not exist, the name is wrong or the type of the object is wrong. The REST-API can also generate a more detailed error for unknown module commands.

Comment by markus makela [ 2023-07-13 ]

The REST-API will generate a more precise error in 23.08 that tells the expected type of the object if a mismatch of some sorts is found.

Generated at Thu Feb 08 04:30:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.