Kaab bin Malik reported,

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

Bukhari 3951

Sahih

حدثني يحيى بن بكير حدثنا الليث عن عقيل عن ابن شهاب عن عبد الرحمن بن عبد الله بن كعب أن عبد الله بن كعب قال سمعت

كعب بن مالك رضي الله عنه يقول

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

البخاري 3951صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Expeditions
Chapter
Story of the battle of Badr
Numbering
Darussalam 3951
Bukhari 3951