The Messenger of Allah ﷺ said, "Whoever takes an oath and then sees something better than it, let him make expiation for his oath and do what is better."
أخبرنا عمرو بن علي قال حدثنا يحيى عن عبيد الله بن الأخنس قال
أن رسول الله ﷺ قال من حلف على يمين فرأى غيرها خيرا منها فليكفر عن يمينه وليأت الذي هو خير
Its isnad is hasan. Ahmad: 2/212 narrated it at length from the hadith of Ubaydullah, and it is found in al-Kubra, no. 4723. The hadith has corroborating narrations in Ibn Hibban, no. 1180, and elsewhere.