The Messenger of Allah ﷺ said, "Whoever takes an oath and says, 'If Allah wills,' has made an exception."
أخبرنا يونس بن عبد الأعلى قال حدثنا ابن وهب قال أخبرني عمرو بن الحارث أن كثير بن فرقد حدثه أن نافعا حدثهم
قال رسول الله ﷺ من حلف فقال إن شاء الله فقد استثنى
[Its isnad is sahih] Hakim narrated it: 4/303, from the hadith of Ibn Wahb, through this route, and he graded it sahih, and Dhahabi agreed with him. It is in Kubra, no. 4769. Part of it was mentioned earlier, no. 3824, from the hadith of Nafi, through this route. See also the following hadith.