He had vowed during the days of ignorance to perform itikaf for a night, or a day, at the Kaabah. He asked the Prophet ﷺ about it, and he replied, "Perform the itikaf and fast."
حدثنا أحمد بن إبراهيم حدثنا أبو داود حدثنا عبد الله بن بديل عن عمرو بن دينار عن ابن عمر أن
جعل عليه أن يعتكف في الجاهلية ليلة أو يوما عند الكعبة فسأل النبي ﷺ فقال اعتكف وصم
[Its chain is daif] Nasai recorded it in Sunan al-Kubra, no. 3355, from the hadith of Abdullah bin Budayl, with this wording. Abu Bakr Nisaburi said, "This is a munkar hadith, and Ibn Budayl is daif in hadith." (Daraqutni, 2/200, 201). The sahih version of the hadith does not contain "and fast."