The Messenger of Allah ﷺ said, "Whoever eats forgetfully while fasting should complete his fast, for it was only Allah who fed him and gave him drink."
حدثنا أبو بكر بن أبي شيبة حدثنا أبو أسامة عن عوف عن خلاس ومحمد بن سيرين
قال رسول الله ﷺ من أكل ناسيا وهو صائم فليتم صومه فإنما أطعمه الله وسقاه
Bukhari narrated it in the Book of Oaths and Vows, Chapter: If One Breaks an Oath Forgetfully, etc., hadith no. 6669, from the hadith of Habib, transmitted through him. Muslim narrated it in the Book of Fasting, Chapter: One Who Eats, Drinks, or Has Intercourse Forgetfully Does Not Break the Fast, hadith no. 1155, through another route from Muhammad bin Sirin, transmitted through him.