If a person intends to observe a naafil fast, then he is invited to eat when visiting some relatives and he eats, is there any sin on him, or does he have to repeat that day so long as he intended to fast?.


Praise be to Allaah.
 

If a Muslim intends to fast one day and starts to fast, then
he wants to break that fast, he may do so, because completing a naafil fast
is not obligatory. But it is mustahabb for him to complete it if he has no
reason for not doing so or no reason for breaking it; if there is a reason
for breaking his fast there is no sin in doing so. This is indicated by a
number of ahaadeeth, including the following: 

1 – Muslim (1154) narrated that ‘Aa’ishah (may Allaah be
pleased with her) said: The Prophet (peace and blessings of Allaah be
upon him) entered upon me one day and said: “Do you have anything (any
food)?” We said, “No.” He said, “Then I am fasting.” Then he came to us
another day and we said, “O Messenger of Allaah, we have been given some
hays
(a kind of food made from dates and ghee).” He said, “Show it to
me, for I started the day fasting.” Then he ate. 

Al-Nawawi said: 

This clearly supports the view of al-Shaafa’i and those who
agreed with him, that a naafil fast may be broken, and one may eat during
the day and cancel the fast, because it is naafil, and the person has the
choice whether to start it and continue it. Among those who were of this
view are a number of the Sahaabah, Ahmad, Ishaaq and others, but all of
them, and al-Shaafa’i too, are agreed that it is mustahabb to complete the
fast. Abu Haneefah and Maalik said that it is not permissible to break the
fast and doing so is a sin. This is also the view of al-Hasan al-Basri,
Makhool and al-Nakh’i; they said that it is obligatory for the one who
breaks the fast without an excuse to make it up. Ibn ‘Abd al-Barr said: They
were unanimously agreed that the one who has an excuse for breaking the fast
does not have to make it up. And Allaah knows best. 

2 – Ahmad (26353)
narrated from Umm Haani’ that the Messenger of Allaah (peace and
blessings of Allaah be upon him) entered upon her and called for something
to drink, and drank some, then he passed it to her and she drank some. She
said: “O Messenger of Allaah, I was fasting.” The Messenger of Allaah
(peace and blessings of Allaah be upon him) said: “The one who is observing
a voluntary fast is his own master; if he wishes he may (continue to) fast
and if he wishes he may break his fast.” Classed as saheeh by al-Albaani in
Saheeh al-Jaami’, 3854. 

It says in Tuhfat al-Ahwadhi, commenting on this
hadeeth: 

The ahaadeeth on this topic indicate that it is permissible
for the one who is observing a voluntary fast to break it, especially if he
is invited to eat by a Muslim. 

3 – al-Bayhaqi narrated that Abu Sa’eed al-Khudri said: Some food was made for the Prophet (peace and blessings of Allaah be upon
him) and when it was served a man said: “I am fasting.” The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Your brother has invited you and make this effort for you. Break your fast and make it up later if you wish.” Al-Haafiz said: Its isnaad is hasan.