Ayub said, "I only know it as from the Prophet ﷺ," who said, "Whoever swears an oath and makes an exception has a choice. If he wishes, he may carry out his oath, and if he wishes, he may withdraw without breaking it," or he said, "without sin."
حدثنا إسماعيل حدثنا أيوب عن نافع
أيوب لا أعلمه إلا عن النبي ﷺ قال من حلف فاستثنى فهو بالخيار إن شاء أن يمضي على يمينه وإن شاء أن يرجع غير حنث أو قال غير حرج
Its isnad is sahih. Tirmidhi (369) narrated it through Abdul-Warith and Hammad bin Salama, from Ayub, from Nafi, from Ibn Umar, that the Messenger of Allah ﷺ said, "Whoever swears an oath and says, if Allah wills, then he bears no blame for breaking it."Tirmidhi said, the hadith of Ibn Umar is a hasan hadith, and Ubaydullah bin Umar and others narrated it from Nafi, from Ibn Umar, as a mawquf report, and Salim likewise narrated it from Ibn Umar as mawquf, and we do not know of anyone who raised it to the Prophet except Ayub Sakhtiyani.Ismail bin Ibrahim (that is, Ibn Ulaya, the teacher of Ahmad in this isnad) said, Ayub would sometimes raise it and sometimes not raise it.Abu Dawud (3:220) narrated it through Sufyan and through Abdul-Warith, Nasai (2:141) through Abdul-Warith, and Ibn Majah (1:330) through Abdul-Warith and through Sufyan bin Uyayna, both of them from Ayub, from Nafi, from Ibn Umar with the same meaning, as a marfu report, without mentioning any doubt on Ayub's part about raising it. The narration of Sufyan will come at 4581.So even if Ayub doubted on one occasion, as reported from him by Ibn Ulaya, he was certain on other occasions, as reported from him by trustworthy narrators, Hammad bin Salama, Abdul-Warith bin Saeed, and Sufyan bin Uyayna.