Huzaifa bin Yaman reported,

"What kept me from being present at Badr was nothing other than the fact that I had set out together with my father Husayl. The disbelievers of Quraysh seized us and said, 'You intend to join Muhammad?' We replied, 'We do not intend that. We only intend to go to Medina.' So they took from us a solemn covenant by Allah that we would head straight to Medina and not fight alongside him.""We then came to the Messenger of Allah ﷺ and informed him of what had happened. He said, 'Go on to Medina. We will fulfill our covenant with them and seek Allah's help against them.'"

Azami 7985

Sahih

عن حذيفة بن اليمان قال

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

الأعظمي 7985صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Jihad
Chapter
Treaty with the enemy
Section
Honoring covenants with enemies
Numbering
Jami al-Kamil 7985 (2nd edition)
Azami 7985