Resolver crash while creating a MUC via GraphQL
MongooseIM version: master Installed from: source Erlang/OTP version: kerl 24.2
I greet you, the brave MongooseIM team! Trying to create a MUC via GraphQL, but get the following error:
{
"errors": [
{
"path": [
"muc",
"createInstantRoom"
],
"message": "Unexpected MUCAdminMutation resolver crash",
"extensions": {
"code": "resolver_crash"
}
}
],
"data": {
"muc": {
"createInstantRoom": null
}
}
}
My query:
mutation muc($mucDomain: String!, $name: String!, $owner: JID!, $nick: String!) {
muc {
createInstantRoom(mucDomain: $mucDomain, name: $name, owner: $owner, nick: $nick) {
jid
title
private
usersNumber
}
}
}
Query variables:
{
"mucDomain":"localhost",
"name":"test room",
"owner": "user@localhost",
"nick": "oozer"
}
The log message:
when=2022-09-06T04:54:52.009766+00:00 level=error what=graphql_crash pid=<0.2481.0> at=mongoose_graphql_errors:crash/2:47 type=MUCAdminMutation stack="[{jid,to_lower,[error],[{file,\"jid.erl\"},{line,223}]},{mod_muc_api,address_attributes,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_api.erl\"},{line,539}]},{mod_muc_api,presence,3,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_api.erl\"},{line,519}]},{mod_muc_api,create_instant_room,4,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_api.erl\"},{line,108}]},{mongoose_graphql_muc_admin_mutation,create_instant_room,1,[{file,\"/home/ivan/work/MongooseIM/src/graphql/admin/mongoose_graphql_muc_admin_mutation.erl\"},{line,39}]},{graphql_execute,resolve_field_value,7,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/graphql/src/graphql_execute.erl\"},{line,538}]},{graphql_execute,execute_field,5,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/graphql/src/graphql_execute.erl\"},{line,394}]},{graphql_execute,execute_sset_field,8,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/graphql/src/graphql_execute.erl\"},{line,264}]}]" field=createInstantRoom error=function_clause
I get a similar error when I try to call listRooms and at least one room exists:
~/w/M/mongooseim ❯❯❯ ./bin/mongooseimctl muc listRooms --mucDomain muc.localhost master ◼
{
"data" : {
"muc" : {
"listRooms" : {
// ! the field is empty
"rooms" : [
],
"last" : "someroom",
"index" : 0,
"first" : "someroom",
"count" : 1
}
}
}
}
After the call the room is down. The logs show that:
when=2022-09-06T06:54:04.902725+00:00 level=info what=muc_room_stopping reason="{function_clause,[{jid,to_lower,[null],[{file,\"jid.erl\"},{line,223}]},{mod_muc_room,get_affiliation,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,1435}]},{mod_muc_room,is_occupant_or_admin,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,1198}]},{mod_muc_room,get_roomdesc_reply,3,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,3942}]},{mod_muc_room,handle_sync_event,4,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,648}]},{gen_fsm_compat,handle_msg,8,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/gen_fsm_compat/src/gen_fsm_compat.erl\"},{line,464}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}" pid=<0.2882.0> at=mod_muc_room:terminate/3:769 text="Stopping room's process" sub_host=muc.localhost room=someroom
when=2022-09-06T06:54:04.903108+00:00 level=error pid=<0.2882.0> at=: unstructured_log="** State machine <0.2882.0> terminating \
** Last message in was {'$gen_sync_all_state_event',\
{<0.2902.0>,\
[alias|#Ref<0.1291483110.4227661825.79438>]},\
{get_disco_item,null,<<\"en\">>}}\
** When State == normal_state\
** Data == {state,<<\"someroom\">>,<<\"muc.localhost\">>,<<\"localhost\">>,\
<<\"localhost\">>,\
{all,all,none,all},\
{jid,<<\"someroom\">>,<<\"muc.localhost\">>,<<>>},\
{config,<<>>,<<>>,true,true,true,true,true,true,true,false,\
true,true,false,false,false,false,<<>>,true,200,[],false},\
#{{<<\"user1\">>,<<\"localhost\">>,<<\"web\">>} =>\
{user,\
{jid,<<\"user1\">>,<<\"localhost\">>,<<\"web\">>},\
<<\"user1\">>,moderator,\
{xmlel,<<\"presence\">>,\
[{<<\"to\">>,<<\"[email protected]/user1\">>}],\
[{xmlel,<<\"priority\">>,[],[{xmlcdata,<<\"1\">>}]},\
{xmlel,<<\"c\">>,\
[{<<\"xmlns\">>,<<\"http://jabber.org/protocol/caps\">>},\
{<<\"node\">>,<<\"http://pidgin.im/\">>},\
{<<\"hash\">>,<<\"sha-1\">>},\
{<<\"ver\">>,<<\"lV6i//bt2U8Rm0REcX8h4F3Nk3M=\">>},\
{<<\"ext\">>,<<\"voice-v1 camera-v1 video-v1\">>}],\
[]}]}}},\
#{<<\"user1\">> =>\
[{jid,<<\"user1\">>,<<\"localhost\">>,<<\"web\">>}]},\
#{},\
#{{<<\"user1\">>,<<\"localhost\">>,<<>>} => owner},\
{lqueue,\
{[{<<\"user1\">>,\
{xmlel,<<\"message\">>,\
[{<<\"type\">>,<<\"groupchat\">>},\
{<<\"id\">>,<<\"purple8c79a448\">>},\
{<<\"to\">>,<<\"[email protected]\">>}],\
[{xmlel,<<\"body\">>,[],\
[{xmlcdata,<<\"And another one!\">>}]},\
{xmlel,<<\"delay\">>,\
[{<<\"xmlns\">>,<<\"urn:xmpp:delay\">>},\
{<<\"stamp\">>,<<\"2022-09-06T06:53:49Z\">>},\
{<<\"from\">>,<<\"[email protected]\">>}],\
[{xmlcdata,<<>>}]}]},\
false,1662447229,246}],\
[{<<\"user1\">>,\
{xmlel,<<\"message\">>,\
[{<<\"type\">>,<<\"groupchat\">>},\
{<<\"id\">>,<<\"purple8c79a447\">>},\
{<<\"to\">>,<<\"[email protected]\">>}],\
[{xmlel,<<\"body\">>,[],\
[{xmlcdata,<<\"Some message for friends!\">>}]},\
{xmlel,<<\"delay\">>,\
[{<<\"xmlns\">>,<<\"urn:xmpp:delay\">>},\
{<<\"stamp\">>,<<\"2022-09-06T06:53:44Z\">>},\
{<<\"from\">>,<<\"[email protected]\">>}],\
[{xmlcdata,<<>>}]}]},\
false,1662447224,255}]},\
2,20},\
<<>>,<<>>,false,nil,none,\
{[],[]},\
none,[],90000}\
** Reason for termination = \
** {function_clause,\
[{jid,to_lower,[null],[{file,\"jid.erl\"},{line,223}]},\
{mod_muc_room,get_affiliation,2,\
[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},\
{line,1435}]},\
{mod_muc_room,is_occupant_or_admin,2,\
[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},\
{line,1198}]},\
{mod_muc_room,get_roomdesc_reply,3,\
[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},\
{line,3942}]},\
{mod_muc_room,handle_sync_event,4,\
[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},\
{line,648}]},\
{gen_fsm_compat,handle_msg,8,\
[{file,\
\"/home/ivan/work/MongooseIM/_build/default/lib/gen_fsm_compat/src/gen_fsm_compat.erl\"},\
{line,464}]},\
{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}\
"
when=2022-09-06T06:54:04.904210+00:00 level=error pid=<0.2882.0> at=proc_lib:crash_report/4:525 report="[[{initial_call,{mod_muc_room,init,['Argument__1']}},{pid,<0.2882.0>},{registered_name,[]},{error_info,{exit,{function_clause,[{jid,to_lower,[null],[{file,\"jid.erl\"},{line,223}]},{mod_muc_room,get_affiliation,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,1435}]},{mod_muc_room,is_occupant_or_admin,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,1198}]},{mod_muc_room,get_roomdesc_reply,3,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,3942}]},{mod_muc_room,handle_sync_event,4,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,648}]},{gen_fsm_compat,handle_msg,8,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/gen_fsm_compat/src/gen_fsm_compat.erl\"},{line,464}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]},[{gen_fsm_compat,terminate,7,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/gen_fsm_compat/src/gen_fsm_compat.erl\"},{line,583}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}},{ancestors,[ejabberd_mod_muc_sup_localhost,ejabberd_sup,<0.388.0>]},{message_queue_len,0},{messages,[]},{links,[<0.566.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,2586},{stack_size,29},{reductions,477718}],[]]" label={proc_lib,crash}
when=2022-09-06T06:54:04.904689+00:00 level=error pid=<0.566.0> at=supervisor:do_restart/3:751 report="[{supervisor,{local,ejabberd_mod_muc_sup_localhost}},{errorContext,child_terminated},{reason,{function_clause,[{jid,to_lower,[null],[{file,\"jid.erl\"},{line,223}]},{mod_muc_room,get_affiliation,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,1435}]},{mod_muc_room,is_occupant_or_admin,2,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,1198}]},{mod_muc_room,get_roomdesc_reply,3,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,3942}]},{mod_muc_room,handle_sync_event,4,[{file,\"/home/ivan/work/MongooseIM/src/mod_muc_room.erl\"},{line,648}]},{gen_fsm_compat,handle_msg,8,[{file,\"/home/ivan/work/MongooseIM/_build/default/lib/gen_fsm_compat/src/gen_fsm_compat.erl\"},{line,464}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,226}]}]}},{offender,[{pid,<0.2882.0>},{id,undefined},{mfargs,{mod_muc_room,start_link,undefined}},{restart_type,temporary},{significant,false},{shutdown,brutal_kill},{child_type,worker}]}]" label={supervisor,child_terminated}
Hi, we have to add error handlers for invalid ids. Still, there is an issue with invalid ids in your query.
"name":"test room" should be a valid name part of JID (i.e. it follows similar format as email ids, i.e. no whitespaces).
"name":"test_room", will work to create a room test_room@localhost