Hi,
The pubsub module is not able to convert node id(Nidx) from integer to binary using erlang function integer_to_binary/1.
Below id the error trace.
Any help would be great.
Internal error while processing SQL query:
{error,badarg,[ {erlang,integer_to_binary,[<<"451">>],[]}, {ejabberd_sql,'-generic_escape/0-fun-1-',1,[{file,"src/ejabberd_sql.erl"},{line,632}]}, {node_flat_sql,'-get_affiliation/2-fun-2-',3,[{file,"src/node_flat_sql.erl"},{line,343}]}, {ejabberd_sql,generic_sql_query_format,1,[{file,"src/ejabberd_sql.erl"},{line,627}]}, {ejabberd_sql,generic_sql_query,1,[{file,"src/ejabberd_sql.erl"},{line,623}]}, {ejabberd_sql,sql_query_internal,1,[{file,"src/ejabberd_sql.erl"},{line,547}]}, {ejabberd_sql,sql_query_t,1,[{file,"src/ejabberd_sql.erl"},{line,183}]}, {node_flat_sql,get_affiliation,2,[{file,"src/node_flat_sql.erl"},{line,342}]}]}
Thank you,
Prasad
To further add to this, the
To further add to this, the Nidx is already in binary form, so the below line in node_flat_sql.erl in function get_items/3 is causing the issue:
SNidx = integer_to_binary(Nidx)
Commit for reference:
https://github.com/processone/ejabberd/commit/d201f013b2e02ee33099df90e2...
Commenting above line has fixed the issue.
Extra Information:
I have upgraded from 16.03 to 16.09.37(non stable release), also running Erlang/OTP 19. Please let me know if this scenario could have caused this issue.
Thank you,
Prasad
Since 16.06, the commit
Since 16.06, the commithttps://github.com/processone/ejabberd/commit/d201f013b2e02ee33099df90e2...
added this line to node_flat_sql:get_items as you noticed:
SNidx = integer_to_binary(Nidx),
That Nidx is get from #pubsub_node.id in mod_pubsub.erl:
and include/pubsub.hrl says that it can be integer or binary:
So, when the value is already a binary, that line crashes, as you reported.
I guess the line requires an improvement to handle that the value can already be a binary. There's already a function that checks this, so I committed this fix:
https://github.com/processone/ejabberd/commit/2ab72bcd009536a6bef2be04c7...
If you can try it, please confirm it works or not.
Hi, Thank you for promply
Hi,
Thank you for promply addressing the issue.
Similar changes need to be made to ejabberd_sql.erl file for this to work.https://github.com/processone/ejabberd/pull/1349
Have raised pull request for the same if that is of any help:
The changes have been verified successfully, locally.
Thank you,
Prasad