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:31:15

But if they endeavor to make you associate with Me that of which you have no knowledge, do not obey them but accompany them in ˹this˺ world with appropriate kindness and follow the way of those who turn back to Me ˹in repentance˺. Then to Me will be your return, and I will inform you about what you used to do.  

But if they urge you to ascribe to Me as partner that whereof you have no knowledge, that accords with ˹any˺ reality, then do not obey them. And keep them company in this world honourably, in other words, with decency: dutifulness and kindness — and follow the way of him who returns to Me ˹in penitence˺, with ˹acts of˺ obedience. Then to Me will be your return, and I will inform you of what you used to do, and requite you for it (the ˹entire˺ sentence containing the ‘enjoinder’ ˹verse 14˺ and what comes after it constitutes a parenthetical statement).
القرآن:٣١:١٥

وَإِنْ جَاهَدَاكَ عَلَىٰ أَنْ تُشْرِكَ بِي مَا لَيْسَ لَكَ بِهِ عِلْمٌ فَلَا تُطِعْهُمَا ۖ وَصَاحِبْهُمَا فِي الدُّنْيَا مَعْرُوفًا ۖ وَاتَّبِعْ سَبِيلَ مَنْ أَنَابَ إِلَيَّ ۚ ثُمَّ إِلَيَّ مَرْجِعُكُمْ فَأُنَبِّئُكُمْ بِمَا كُنْتُمْ تَعْمَلُونَ  

{وإن جاهداك على أن تشرك بي ما ليس لك به علم} موافقة للواقع {فلا تطعهما وصاحبهما في الدنيا معروفا} أي بالمعروف البر والصلة {واتبع سبيل} طريق {من أناب} رجع {إليَّ} بالطاعة {ثم إليَّ مرجعكم فأنبئكم بما كنتم تعملون} فأجازيكم عليه وجملة الوصية وما بعدها اعتراض.

See similar narrations below:

Collected by Qurʾān
quran:29:8

And We have enjoined upon man goodness to parents. But if they endeavor to make you associate with Me that of which you have no knowledge, do not obey them. To Me is your return, and I will inform you about what you used to do.  

And We have enjoined on man kindness to his parents, that he should be dutiful towards them; but if they urge you to ascribe to Me as partner that of which you do not have any knowledge, ˹any knowledge˺ that accords with reality, and so is meaningless, then do not obey them, in ˹such incitements to˺ idolatry. To Me will be your return whereat I will inform you of what you used to do, and I will requite you for it.
القرآن:٢٩:٨

وَوَصَّيْنَا الْإِنْسَانَ بِوَالِدَيْهِ حُسْنًا ۖ وَإِنْ جَاهَدَاكَ لِتُشْرِكَ بِي مَا لَيْسَ لَكَ بِهِ عِلْمٌ فَلَا تُطِعْهُمَا ۚ إِلَيَّ مَرْجِعُكُمْ فَأُنَبِّئُكُمْ بِمَا كُنْتُمْ تَعْمَلُونَ  

{ووصينا الإنسان بوالديه حسناً} أي إيصاء ذات حسن بأن يبرهما {وإن جاهداك لتشرك بي ما ليس لك به} بإشراكه {علم} موافقة للواقع فلا مفهوم له {فلا تطعهما} في الإشراك {إليَّ مرجعكم فأنبئكم بما كنتم تعملون} فأجازيكم به.