-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled function clause exception when retrieving queue for nonexistent virtual host #10901
Comments
@LoisSotoLopez I mean, good to see someone working on this but honestly, polling over HTTP API when a virtual host does not exist? This is as low a priority as it gets. Perhaps CloudAMQP, a company that directly makes money off of RabbitMQ and has been doing that since 2012, should consider more substantial contributions. |
For the record Lois just started working with RabbitMQ a few weeks ago. A low priority task is the perfect first step to get familiar with the concepts and notions of RabbitMQ, the code base which is admittedly complex, custom solutions and peculiarities. This is the slow way forward for more substantial contributions. Please expect some more low priority contributions. Thanks for understanding. |
Before this change some Management API endpoints handling POST requests crashed and returned HTTP 500 error code when called for a non-existing vhost. The reason was that parsing of the virtual host name could return a `not_found` atom which could potentially reach later steps of the data flow, which expect a vhost name binary only. Instead of returning `not_found`, now the code fails early with HTTP 400 error code and a descriptive error reason. See more details in the github issue Fixes #10901 (cherry picked from commit dfddfe3)
Describe the bug
Retrieving messages on a queue through
rabbit_mgmt_wm_queue_get.erl
for an invalid virtual host results on an unhandledfunction_clause
exception.This issue seems to have been introduced by commit 439c2b4 , more precisely by this change .
While on the previous version of the file the
rabbit_vhost:assert/1
was called before searching for the vhost data on the Mnesia table, the current version callsrabbit_db_rtparams:get_all/2
. As seen below, that function ends up calling torabbit_vhost:assert/1
on the vhost too (atget_all_in_mnesia/2
) but only if theVHostName
parameter passed toget_all/2
is either abinary()
or the'_'
atom.That new type check is incompatible with a previous step on the data flow, on
rabbit_mgmt_wm_queue_get
where the parsing of the request leads to the variable for the virtual host having thenot_found
atom as value if the virtual host does not exist.The parsing is done by
rabbitmq-server/deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl
Line 45 in e4da70d
rabbitmq-server/deps/rabbitmq_management/src/rabbit_mgmt_util.erl
Line 211 in e4da70d
rabbitmq-server/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_access_control.erl
Line 222 in e4da70d
Expand this to see the stacktrace associated to the **Reproduction steps** below.
Reproduction steps
docker run --rm -it -p 15673:15672 rabbitmq:3.13.0-management
curl -sv -u guest:guest -X POST -H 'Content-Type: application/json' --data '{ "ackmode": "reject_requeue_true", "encoding": "auto", "count": 1 }' http://localhost:15673/api/queues/does-not-exist/foo/get
Expected behavior
A 404 HTTP error code specifying the provided virtual host does not exist.
Additional context
We are already working on this.
The text was updated successfully, but these errors were encountered: