אַ֥שְֽׁרֵי הַגֶּ֗בֶר אֲשֶׁר־שָׂ֣ם יְ֭הֹוָה מִבְטַח֑וֹ וְֽלֹא־פָנָ֥ה אֶל־רְ֝הָבִ֗ים וְשָׂטֵ֥י כָזָֽב׃
Heureux l’homme qui cherche sa sécurité en l’Éternel, et ne se tourne pas vers les orgueilleux et les amis du mensonge!
Kli Yakar
“And it was at the end of two years.” Since it is not explicitly stated in the text when these two years began, our Rabbis taught (Genesis Rabbah 89:2) that these two years were added to his prison sentence beyond what was originally decreed upon him, because he placed his trust in the chief cupbearer, as it is said Fortunate is the man who makes God his trust and does not turn to the arrogant ones (Psalms 40:5) — these being the Egyptians who were called rahav [arrogant]. One might question why it says who makes God his trust [asher sam Hashem mivtacho] when it should have said “who places his trust in God” [asher sam baHashem mivtacho], as it is written Blessed is the man who trusts in God, and God will be his trust (Jeremiah 17:7). Besides the apparent redundancy in this verse, the language also needs explanation regarding the phrase and God will be his trust. Furthermore, it is difficult to understand why the Egyptians are called rehabim [arrogant ones] and not by their well-known name.
Ibn Ezra
רהב Tyrant.10A. V., Rahab. The proud. Comp. רהבים tyrants (Ps. 40:5; 87:4).
Rashi
וישכחהו AND HE FORGOT HIM afterwards. Because Joseph had placed his trust in him that he should remember him he was doomed to remain in prison for two years. So it is said (Psalms 40:5) “Happy is the man who maketh the Lord his trust and turneth not to (רהבים) the arrogant” — i.e. doth not trust in the Egyptians who are called arrogant (Genesis Rabbah 89:3 cf. Isaiah 30:7).