Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:33:5

Call them by ˹the names of˺ their fathers; it is more just in the sight of Allah. But if you do not know their fathers - then they are ˹still˺ your brothers in religion and those entrusted to you. And there is no blame upon you for that in which you have erred but ˹only for˺ what your hearts intended. And ever is Allah Forgiving and Merciful.  

Instead, attribute them to their ˹true˺ fathers. That is more equitable, ˹that is˺ more just, in the sight of God. If you do not know their ˹true˺ fathers, then they are your brethren in religion and ˹as˺ your associates. And you would not be at fault for any mistake you make, in this respect, except, in, what your hearts may premeditate, after the prohibition ˹has been issued˺. And God is Forgiving, of whatever you said before the prohibition ˹was issued˺, Merciful, to you in this respect.
القرآن:٣٣:٥

ادْعُوهُمْ لِآبَائِهِمْ هُوَ أَقْسَطُ عِنْدَ اللَّهِ ۚ فَإِنْ لَمْ تَعْلَمُوا آبَاءَهُمْ فَإِخْوَانُكُمْ فِي الدِّينِ وَمَوَالِيكُمْ ۚ وَلَيْسَ عَلَيْكُمْ جُنَاحٌ فِيمَا أَخْطَأْتُمْ بِهِ وَلَٰكِنْ مَا تَعَمَّدَتْ قُلُوبُكُمْ ۚ وَكَانَ اللَّهُ غَفُورًا رَحِيمًا  

لكن {ادعوهم لآبائهم هو أقسطُ} أعدل {عند الله، فإن لم تعلموا آباءهم فإخوانكم في الدين ومواليكم} بنو عمكم {وليس عليكم جناح فيما أخطأتم به} في ذلك {ولكن} في {ما تعمدت قلوبكم} فيه أي بعد النهي {وكان الله غفورا} لما كان من قولكم قبل النهي {رحيما} بكم في ذلك.