A funeral was brought to the Prophet ﷺ for him to pray over.He asked, "Does he owe any debt?"They replied, "No."So he prayed over him.Then another funeral was brought to him, and he asked, "Does he owe any debt?"They replied, "Yes."He said, "Pray over your companion yourselves."Abu Qatada said, "His debt is upon me, Messenger of Allah."So he prayed over him.
أن النبي ﷺ أتي بجنازة ليصلي عليها، فقال: هل عليه من دين؟ قالوا: لا. فصلى عليه، ثم أتي بجنازة أخرى، فقال: هل عليه من دين؟ قالوا: نعم. قال: صلوا على صاحبكم قال أبو قتادة: علي دينه يا رسول الله، فصلى عليه.
Bukhari narrated it in the Book of Guarantees (2295) from Abu Asim, from Yazid bin Abu Ubayd, from Salama bin Akwa, who mentioned it. It has already been mentioned, along with what shares its meaning, in the Book of Funerals.