No doubts imams are Perfect. Yes Allah has given them knowledge but it is His decision that how much knowledge has to given and when it has to given what He has to show what He has to hide.
فَتَعَالَى اللَّهُ الْمَلِكُ الْحَقُّ وَلَا تَعْجَلْ بِالْقُرْآنِ مِن قَبْلِ أَن يُقْضَىٰ إِلَيْكَ وَحْيُهُ وَقُل رَّبِّ زِدْنِي عِلْمًا
Supremely exalted is therefore Allah, the King, the Truth, and do not make haste with the Quran before its revelation is made complete to you and say: O my Lord! increase me in knowledge.
Sura Taha ayah 114.
The Knower of the unseen! so He does not reveal His secrets to any,
Except to him whom He chooses as an apostle; for surely He makes a guard to march before him and after him,
Surah Jin ayah 26,27
Allah is final authority. Death is decision of Allah and our aim kah are the best examples who have accepted will of Allah