Skip to content

Log error with INFO loglevel when receiving an unexpected IQ #4503

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

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/ejabberd_local.erl
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,34 @@
To :: jid:jid(),
Acc :: mongoose_acc:t(),
IQ :: jlib:iq()) -> mongoose_acc:t().
process_iq_reply(From, To, Acc, #iq{id = ID} = IQ) ->
process_iq_reply(From, To, Acc, #iq{type = Type, id = ID} = IQ) ->
case get_iq_callback_in_cluster(ID, Acc) of
{ok, Callback} ->
Callback(From, To, Acc, IQ);
_ ->
Other ->
%% 8.2.3. IQ Semantics (https://www.rfc-editor.org/rfc/rfc6120)
%% An entity that receives a stanza of type "result" or "error" MUST
%% NOT respond to the stanza by sending a further IQ response of
%% type "result" or "error".
%% (Do not reply).
?LOG_INFO(#{what => dropped_iq_reply,

Check warning on line 140 in src/ejabberd_local.erl

View check run for this annotation

Codecov / codecov/patch

src/ejabberd_local.erl#L140

Added line #L140 was not covered by tests
text => <<"User send an unexpected IQ "
" type=", (atom_to_binary(Type))/binary,
". Ignore the stanza.">>,
reason => Other, acc => Acc}),

Check warning on line 144 in src/ejabberd_local.erl

View check run for this annotation

Codecov / codecov/patch

src/ejabberd_local.erl#L144

Added line #L144 was not covered by tests
Acc
end.

-spec get_iq_callback_in_cluster(id(), mongoose_acc:t()) ->
{ok, callback()} | {error, term()}.
get_iq_callback_in_cluster(ID, Acc) ->
get_iq_callback_in_cluster(ID, _Acc) ->
%% We store information from which node the request is originating in the ID
case parse_iq_id(ID) of
local_node ->
get_iq_callback(ID);
{remote_node, NodeName} ->
rpc:call(NodeName, ?MODULE, get_iq_callback, [ID]);
{error, Reason} ->
?LOG_ERROR(#{what => parse_iq_id_failed,
reason => Reason, acc => Acc}),
{error, Reason}
end.

Expand Down