Language:
كتاب المغازى
64  
Military Expeditions led by the Prophet (pbuh) (Al-Maghaazi)
(3)
Chapter: The story of the Ghazwa of Badr
(3)
باب قِصَّةُ غَزْوَةِ بَدْرٍ
Sahih al-Bukhari 3951

Narrated Ka`b bin Malik:

I never failed to join Allah's Messenger (ﷺ) in any of his Ghazawat except in the Ghazwa of Tabuk. However, I did not take part in the Ghazwa of Badr, but none who failed to take part in it, was blamed, for Allah's Messenger (ﷺ) had gone out to meet the caravans of (Quraish, but Allah caused them (i.e. Muslims) to meet their enemy unexpectedly (with no previous intention) .

حَدَّثَنِي يَحْيَى بْنُ بُكَيْرٍ، حَدَّثَنَا اللَّيْثُ، عَنْ عُقَيْلٍ، عَنِ ابْنِ شِهَابٍ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ عَبْدِ اللَّهِ بْنِ كَعْبٍ، أَنَّ عَبْدَ اللَّهِ بْنَ كَعْبٍ، قَالَ سَمِعْتُ كَعْبَ بْنَ مَالِكٍ ـ رضى الله عنه ـ يَقُولُ لَمْ أَتَخَلَّفْ عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم فِي غَزْوَةٍ غَزَاهَا إِلاَّ فِي غَزْوَةِ تَبُوكَ، غَيْرَ أَنِّي تَخَلَّفْتُ عَنْ غَزْوَةِ بَدْرٍ، وَلَمْ يُعَاتَبْ أَحَدٌ تَخَلَّفَ عَنْهَا، إِنَّمَا خَرَجَ رَسُولُ اللَّهِ صلى الله عليه وسلم يُرِيدُ عِيرَ قُرَيْشٍ، حَتَّى جَمَعَ اللَّهُ بَيْنَهُمْ وَبَيْنَ عَدُوِّهِمْ عَلَى غَيْرِ مِيعَادٍ‏.‏
Reference : Sahih al-Bukhari 3951
In-book reference : Book 64, Hadith 3
USC-MSA web (English) reference : Vol. 5, Book 59, Hadith 287
  (deprecated numbering scheme)