The Imams had around them non-Imamis, deviants, and people who did Ghuluw. How do we know the narrations we have today are actually from the Imams themselves and through narrators who did not corrupt the narration?
There is a full field of knowledge called E'lm Al-Rijaal which deals with every narrator and searching and assessing his authenticity. Deviat persons are known by our scholars of E'lm Al-Rijaal and their narrations are never accepted.
Famous Shia books on E'lm Al-Rijaal are like Kitab Al-Rijaal by Al-Najaashi (450 Hijri),
Rijaal Al-Kashshi (350 Hijri) ,
and Al-Fahrist by Al-Shaikh Al-Tousi (460 Hijri) ,
Ma'aalim Al-Ulama' by Ibn Sharashoob 588 hijri.
Khulasat Al Awwal by Al-Allama Al-Hilli 726 hujri.
Tanqeeh Al-Maqaal by Al-Mamaqani 1351 hujri.
and Mu'jam Rijaal Al-Hadeeth by Al-Khoei 1413 hijri.
We only accept narrations from authentic narrators who were always in the right path.
Wassalam.