The Messenger of Allah ﷺ said, "Whoever vows to obey Allah, let him obey Him, and whoever vows to disobey Allah, let him not disobey Him."
حدثنا القعنبى عن مالك عن طلحة بن عبد الملك الأيلي عن القاسم
قال رسول الله ﷺ من نذر أن يطيع الله فليطعه ومن نذر أن يعصي الله فلا يعصه
Bukhari narrated it in the Book of Oaths and Vows, the chapter on vows in obedience etc., hadith no. 6696, 6700, from the hadith of Malik through this same chain, and it is found in the Muwatta (Yahya's version): 2/476.