The Messenger of Allah ﷺ said, "Whoever takes an oath and says, 'If Allah wills,' has made an exception."
أخبرنا نوح بن حبيب قال أنبأنا عبد الرزاق قال أنبأنا معمر عن ابن طاوس عن أبيه
قال رسول الله ﷺ من حلف على يمين فقال إن شاء الله فقد استثنى
Sourcing, its chain of transmission is sahih. Tirmidhi narrated it in the book of vows and oaths, chapter on what has been said about making an exception in an oath, no. 1532, and Ibn Majah in the book of expiations, chapter on making an exception in an oath, no. 2104, from the hadith of Abdul-Razzaq through this route. Ibn Hibban graded it sahih, no. 1185, and it has corroborating narrations.