Sahih Muslim 1155
Sahih Muslim · Book 13: The Book of Fasting · The one who eats, drinks, or has intercourse by mistake does not break his fast
Abu Huraira reported Allah's Messenger (ﷺ) as saying:
وَحَدَّثَنِي عَمْرُو بْنُ مُحَمَّدٍ النَّاقِدُ ، حَدَّثَنَا إِسْمَاعِيلُ بْنُ إِبْرَاهِيمَ ، عَنْ هِشَامٍ الْقُرْدُوسِيِّ ، عَنْ مُحَمَّدِ بْنِ سِيرِينَ ، عَنْ أَبِي هُرَيْرَةَ ، - رضى الله عنه - قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " مَنْ نَسِيَ وَهُوَ صَائِمٌ فَأَكَلَ أَوْ شَرِبَ فَلْيُتِمَّ صَوْمَهُ فَإِنَّمَا أَطْعَمَهُ اللَّهُ وَسَقَاهُ " .
If anyone forgets that he is fasting and eats or drinks he should complete his fast, for it is only Allah Who has fed him and given him drink.