crossbario / autobahn-cpp

WAMP for C++ in Boost/Asio
https://crossbar.io/autobahn
Boost Software License 1.0
251 stars 104 forks source link

Content of CALL error not compatible with other WAMP clients #197

Closed bmotmans closed 5 years ago

bmotmans commented 5 years ago

Describe the bug I am working on a project where WampSharp acts as a WAMP host and autobahn-cpp is used to call RPC methods.

When a RPC call is invoked that is not yet registered, the error "wamp.error.no_such_procedure" is returned.

According to the protocol https://wamp-proto.org/_static/wamp_latest.html#call-error the format should be: [ERROR, CALL, CALL.Request|id, Details|dict, Error|uri] (or 2 other variants) Where "Details" must be a dictionary. The protocol lists the following example: [8, 48, 7814135, {}, "wamp.error.no_such_procedure"]

However, WampSharp uses the value null instead of an empty dictionary, for example: [8,48,1,null,"wamp.error.no_such_procedure",["no procedure 'master.primary.index.get' registered"]]"

When autobahn-cpp processes the error, it expects the 'Details' parameter to be a dictionary, which is not the case. This causes a protocol error exception to be thrown, instead of reporting the actual no_such_procedure error.

see wamp_session.ipp

inline void wamp_session::process_error(wamp_message&& message)

// Details
    if (!message.is_field_type(3, msgpack::type::MAP)) {
    throw protocol_error("invalid ERROR message structure - Details must be a dictionary");
    }

Expected Behavior For the sake of compatibility, I think both WampSharp and autobahn-cpp should be patched. WampSharp should return an empty Details dictionary when a no_such_procedure error occurs. Autobahn-cpp should treat 'null' values for the Details dictionary as an empty dictionary.

Platforms / Versions WampSharp 18.10.1 running on .NET 4.7.2 on Windows 7 SP1 autobahn-cpp 18.4.1 compiled with MSVC 15.7.3

oberstet commented 5 years ago

Autobahn-cpp should treat 'null' values for the Details dictionary as an empty dictionary.

no, this is not compliant with the spec