Kaab bin Malik reported,

I never stayed behind from any expedition the Messenger of Allah ﷺ undertook except the expedition of Tabuk, though I had also stayed behind from the expedition of Badr. But no one was reproached for missing Badr, for the Messenger of Allah ﷺ had only set out intending to intercept the caravan of Quraysh, until Allah brought them and their enemy together without any prior appointment… the rest of the hadith.

Azami 8717

Sahih

عن كعب بن مالك قال

لم أتخلف عن رسول الله ﷺ في غزوة غزاها إلا في غزوة تبوك، غير أني تخلفت عن غزوة بدر، ولم يعاتب أحد تخلف عنها، إنما خرج رسول الله ﷺ يريد عير قريش، حتى جمع الله بينهم وبين عدوهم على غير ميعاد… الحديث.

الأعظمي 8717صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Biography of the Prophet ﷺ
Chapter
Expedition of Badr
Section
Prophet ﷺ did not go out to Badr to fight, rather it was
Numbering
Jami al-Kamil 8717 (2nd edition)
Azami 8717