Praise be to Allah.
Obligation of forming the intention the night before observing an obligatory fast
It is obligatory to form the intention the night before for every obligatory fast, which includes making up missed Ramadan fasts, because the Prophet (blessings and peace of Allah be upon him) said: “Whoever did not intend to fast before dawn, there is no fast for him.” Narrated by Abu Dawud (2454), at-Tirmidhi (730) and an-Nasa’i (2331). According to the version narrated by an-Nasa’i: “Whoever does not form the intention to fast at night, before dawn, there is no fast for him.” This hadith was classed as sahih by al-Albani in Sahih Abi Dawud.
At-Tirmidhi (may Allah have mercy on him) said: What this means, according to some of the scholars, is that there is no [valid] fast for the one who does not form the intention to fast before dawn breaks, in Ramadan, or when making up a missed Ramadan fast, or when fasting in fulfilment of a vow, because if he does not form the intention from the night before, it is not valid [as an obligatory fast].
In the case of voluntary fasts, on the other hand, it is permissible to form the intention to fast after dawn has broken. This is the view of ash-Shafa‘i, Ahmad and Ishaq. End quote.
The view of Abu Hanifah (may Allah have mercy on him) is that the fast is valid if the intention is formed on the same day.
Ibn Qudamah said: If it is an obligatory fast – such as fasting in Ramadan, in the month itself or making up a missed Ramadan fast, or fasting in fulfilment of a vow or as an act of expiation – it is stipulated that the intention should be formed the night before, according to our imam, and Malik, and ash-Shafa‘i.
Abu Hanifah said: In the case of a Ramadan fast and any fast that one is obliged to do, it is acceptable to form the intention on the same day."(Al-Mughni 3/109).
Is it valid to observe a make-up fast with an uncertain intention?
If your intention was that if you got up and ate sahur, then you would fast, this is an uncertain intention, with which the fast is not valid [as an obligatory fast].
It says in al-Furu‘ (4/459): According to our madhhab, if a person is uncertain about not fasting, or he intends that he will break his fast at a particular time, or that if he finds food he will eat, otherwise he will continue his fast, then by analogy with the difference of opinion regarding prayer, it was said that this renders the fast invalid, because his intention was not firm. Hence it is not valid to start fasting with such an [uncertain] intention. End quote.
Some of the jurists regarded the fast of one who says, “If tomorrow is Ramadan, then I will fast” as valid, because he does not know whether tomorrow will be Ramadan, so his hesitation is based on uncertainty as to whether it will be proven that the month has begun, not on uncertainty in his intention as to whether he will fast or not. Hence if one for whom it is permissible not to fast says on some night in Ramadan: “Tomorrow maybe I will fast and maybe I will not fast,” then he decides after dawn has broken that he will fast, his fast is not valid because of the uncertainty in his intention."(Ash-Sharh al-Mumti‘ 6/362).
Based on that, if you got up before the adhan of Fajr and formed the intention to fast, your fast is valid.
If you got up after the adhan, then your fast is not valid as a make-up fast, because your intention was conditional and was not firm.
And Allah knows best.