-
Describe the bugwhen a shovel declares queue/exchange name that contains special characters, say '😍' or any CJK characters, status page will crashes. the shovel cannot be removed with shovel management plugin either. this happens at least in versions of 3.12.x, 3.13.x, 4.0.x. Reproduction steps
rabbitmqctl set_parameter shovel 'test' \
'{
"ack-mode": "on-confirm",
"dest-add-forward-headers": false,
"dest-queue": "😍",
"dest-protocol": "amqp091",
"dest-uri": "amqp://",
"src-delete-after": "never",
"src-protocol": "amqp091",
"src-queue": "😍",
"src-uri": "amqp://"
}'
rabbitmqctl clear_parameter shovel 'test' The Expected behaviorshovel should declare source and destination automatically, no matter what characters are in their valid names. Additional contextit may caused by a erlang:list_to_binary/1 call with the parameter in unicode encoding somehow, instead of utf-8. it crashes since elements in the list may be larger than 255. the unicode:characters_to_binary/1 should be used instead? logs are attached. sample lines are,
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
CJK characters, emojis and so on are not allowed in AMQP 0-9-1 entity names (such as queues). I am less sure about AMQP 1.0 but this is the fundamental limitation. In fact, the exception does not come from Shovel, it comes from a |
Beta Was this translation helpful? Give feedback.
-
@bpint for AMQP 0-9-1, this is a "won't fix". For AMQP 1.0, we will have to investigate what the requirements and options are. In any case, this is a very fundamental limitation that stems from the original protocol RabbitMQ implemented, so it's not a matter of swapping a few functions for their Unicode-aware equivalents. |
Beta Was this translation helpful? Give feedback.
-
@michaelklishin thanks a lot for your quick response. as i know, many users widely use non-ascii characters in names of queues, exchanges, shovels, usernames, etc. when i create a queue with CJK names, it is totally fine. the queue can be created, deleted, bound, published to, consume from, and so on. shovel even works well with them, only if they are already declared. that give me the impression that those characters are valid for any names. the names mentioned above are encoded in utf-8 internally and represented in binaries. the shovel plugin itself, stores source and destination queue names in JSON parameters (utf-8), and use them as strings/binaries (encoded with utf-16) to declare them, and displayed in utf-8 in web console. that is a different and strange behavior. since there are many such names in production systems, i will investigate deeper on it. |
Beta Was this translation helpful? Give feedback.
-
@michaelklishin here's my findings on this, the stack is basicly,
ensure_queue(Conn, Queue, XArgs) ->
{ok, Ch} = amqp_connection:open_channel(Conn),
try
amqp_channel:call(Ch, #'queue.declare'{queue = Queue,
passive = true})
catch exit:{{shutdown, {server_initiated_close, ?NOT_FOUND, _Text}}, _} ->
%% ...
end.
format_soft_error(#amqp_error{name = N, explanation = E, method = M}) ->
io_lib:format("operation ~ts caused a channel exception ~ts: ~ts", [M, N, E]).
amqp_exception_explanation(Text, Expl) ->
ExplBin = list_to_binary(Expl),
CompleteTextBin = <<Text/binary, " - ", ExplBin/binary>>,
if size(CompleteTextBin) > 255 -> <<CompleteTextBin:252/binary, "...">>;
true -> CompleteTextBin
end. here Expl is, [78,79,84,95,70,79,85,78,68,32,45,32,
110,111,32,113,117, 101,117,101,32,
39,128525,39,
32,105,110,32,118,104,111, 115,116,32,
39,47,39] which is actually string it seems all other codes in rabbitmq are compatible with unicode names. here i propose the following change to fix it, diff --git a/deps/rabbit_common/src/rabbit_binary_generator.erl b/deps/rabbit_common/src/rabbit_binary_generator.erl
index eb256052c0..ec0ddc4e76 100644
--- a/deps/rabbit_common/src/rabbit_binary_generator.erl
+++ b/deps/rabbit_common/src/rabbit_binary_generator.erl
@@ -228,8 +228,5 @@ lookup_amqp_exception(Other, Protocol) ->
{ShouldClose, Code, Text, none}.
amqp_exception_explanation(Text, Expl) ->
- ExplBin = list_to_binary(Expl),
- CompleteTextBin = <<Text/binary, " - ", ExplBin/binary>>,
- if size(CompleteTextBin) > 255 -> <<CompleteTextBin:252/binary, "...">>;
- true -> CompleteTextBin
- end.
+ LimitedText = io_lib:format("~ts - ~ts", [Text, Expl], [{chars_limit, 255}]),
+ unicode:characters_to_binary(lists:flatten(LimitedText)).
by the way, i have also tested shovel with AMQP 1.0 protocol. this unicode problem does not exist for AMQP 1.0 addresses. thanks a lot, and please consider this minor change. |
Beta Was this translation helpful? Give feedback.
sorry it took some time. my first PR to rabbitmq. #12888
@michaelklishin thanks again for your kind help!