What Happens If You Accidentally Eat during Ramadan
Question

What is the ruling on breaking a voluntary fast by mistake?
Praise be to Allah.Al-Bukhari (6669) and Muslim (1155) narrated that Abu Hurayrah (may Allah be pleased with him) said: The Prophet (peace and blessings of Allah be upon him) said: “Whoever forgets he is fasting and eats or drinks , let him complete his fast for it is Allah Who has fed him and given him to drink.” 
It was also narrated that he does not have to offer expiation or make up that fast. 
Ibn Khuzaymah (1999) narrated from Abu Hurayrah that the Prophet (peace and blessings of Allah be upon him) said: “Whoever breaks his fast in Ramadan by mistake does not have to make up that day or offer expiation.” (Classed as hasan by al-Albani in Sahih Ibn Khuzaymah.) 
Al-Daraqutni narrated from Abu Sa’id al-Khudri that the Prophet (peace and blessings of Allah be upon him) said: “Whoever eats in the month of Ramadan by mistake does not have to make up that day.” 
Al-Hafiz said: 
“Although its isnad (chain of transmission) is weak, it may still be considered sound because there are corroborating reports. The least that could be said about it is that it is hasan, so it may be quoted as evidence. Reports that are less strong than this have been quoted as evidence with regard to many issues. It may also be supported by the fact that a number of the Companions issued fatwas that are in agreement with this hadith without any one of the Companions having a different view, as was stated by Ibn al-Mundhir, Ibn Hazm and others, and ‘Ali ibn Abi Talib, Zayd ibn Thabit, Abu Hurayrah, and Ibn ‘Umar. And it is in accordance with the words of Allah (interpretation of the meaning): 
“but He will call you to account for that which your hearts have earned.” [al-Baqarah 2:225]
Forgetfulness is not something which is earned by the heart. 
This hadith tells of the kindness of Allah to His slaves and how He makes things easier for them and alleviates hardship.” 
The majority of scholars quote these hadiths as evidence that whoever forgets that he is fasting and breaks the fast, his fast is still valid, and he should complete his fast, and he does not have to make it up or offer any expiation. The general meaning of the hadith covers both obligatory and nafl fasts; there is no difference between the two. 
Al-Shafi’i said in al-Umm (2/284): 
“If a fasting person eats or drinks in Ramadan or in a fast observed in fulfillment of a vow or as an expiation, or a fast that is obligatory for some reason, or a voluntary fast , out of forgetfulness, then his fast is complete and he does not have to make it up.”  
Al-Nawawi said: 
“This is evidence to support the view of the majority: if the fasting person eats or drinks or has intercourse because of forgetfulness, then he does not break his fast. Among those who were of this view are al-Shafi’i, Abu Hanifah, Dawud and others.” 
Al-Hafiz said: 
“An interesting story was narrated by ‘Abd al-Razzaq from ‘Amr ibn Dinar: that a person came to Abu Hurayrah and said: “I started fasting in the morning then I forgot and ate.” He said, “It does not matter.” He said: “Then I entered upon someone and by mistake I ate and drank.” He said, “It does not matter, Allah has fed you and given you to drink.” Then he said:  “I entered upon another person and forgot, and ate.” Abu Hurayrah said: “You are a person who is not used to fasting.”
And Allah knows best.