Eating or drinking forgetfully does not break your fast. However, eating or drinking mistakenly or accidently does break your fast.
عَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ، عَنِ النَّبِيِّ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ، قَالَ: إِذَا نَسِيَ فَأَكَلَ وَشَرِبَ، فَلْيُتِمَّ صَوْمَهُ، فَإِنَّمَا أَطْعَمَهُ اللَّهُ وَسَقَاهُ
Abu Huraira (May Allah Most High be pleased with him) narrated that the Prophet ﷺ said, ‘If one eats or drinks forgetfully then he should complete his fast. For indeed it was Allah (Most High) who fed him and gave him to drink.’ (Sahih al-Bukhari, 1933).
The Hadith above is clear regarding the fact that eating or drinking forgetfully does not break your fast. However, it does not speak about eating or drinking mistakenly, accidently, or inadvertently. This is why the Hanafi scholars differentiated between eating or drinking forgetfully and doing so accidently.
Eating or drinking forgetfully means that the individual in question was unaware or unconscious of the fact that he is fasting at the time of eating or drinking. As for eating or drinking mistakenly or accidently, the individual in question is aware that he is fasting and is trying not to swallow food or drink, but he does so inadvertently or accidently. A good example of nullifying the fast accidently is of a person who is performing Wudu whilst fasting, he is conscious that he is fasting so trying not to swallow any of the water. Nevertheless, he ends up swallowing a little, the fast is nullified. There is no sin upon him but he must make this fast up.
وَأَمَّا إِنْ أَفْطَرَ خَطَأً أَوْ مُكْرَهًا فَإِنَّهُ يَقْضِي فَقَطْ
As for his nullifying the fast mistakenly or in coercion then he will have to make it up (no Kaffaarah is required). (Imam Ali al-Qari, Mirqaat al-Mafateeh).
In the Nass above Imam Ali al-Qari mentions the position of the Hanafi Madhab regarding a fast that is nullified mistakenly. Despite this differentiation one must be vigilant against Waswasah, and not assume that the fast is nullified every time he performs Wudu. Rather the fast will remain valid unless he is sure that he swallowed water.
And Allah Most High Knows Best.
-Answered by Shaykh Noorud-deen Rashid (11.04.2022)
Does a blood test break the fast?
Learning through Q and A
See also (video):