Do you have any sl_send_reply()/send_reply()/t_reply() in kamailio.cfg that has the second parameter a variable? If yes, that variable might not be set (or set to an empty string)...
Kamailio doesn't send many 500 responses internally in the code, so likely is from kamailio.cfg.