Chovos Halevavos - Shaar Habitachon Chapter 3 - חובות הלבבות שער הביטחון פרק שלישי
מי שיבטח על הבורא והוא ממרה אותו, כמה הוא סכל וכמה דעתו חלושה והכרתו! כי הוא רואה כי מי שנתמנה לו מבני אדם על דבר, כשהוא מצווה אותו להתעסק בצורך מצרכיו או מזהיר אותו מדבר, ויעבור על מצוותיו ויגיע לממונה עוברו על מצוותו - כי יהיה הסיבה החזקה להימנע ממנו להיעשות מה שבטח עליו בו. כל שכן מי שעבר על חוקי האלוהים ומצוותיו אשר יעד, והועיד עליהם שתהיה תוחלת הבוטח עליו נכזבה כשימרהו, ולא יהיה ראוי להיקרא בשם בוטח באלוהים.
But, if one trusts in G-d and rebels against Him, how foolish is he, how weak is his intellect and his understanding! For he can see in this world that if an employer appoints a man to do something or refrain from doing something and the man disobeys the instruction, this will be the strongest factor in the employer's refusing to fulfill his side of the deal. All the more so, for one who disobeys the commandments of G-d, for which G-d Himself testified that one who trusts in Him and disobeys Him will have his hopes foiled and his trust will be considered hypocritical. And he is not even worthy of being called one who has faith in Hashem.
This seems to be in contradiction of the Following Medrash:
Yalkut Shimoni Tehillim 32 / #719 - - ילקוט שמעוני תהילים לב רמז תשיט
רבי אליעזר ורבי תנחום בשם רבי ירמיה אפילו רשע ובוטח בה' חסד יסובבנו
Rabbi Eliezer and Rabbi Tanchum in the name of Rabbi Yirmiya: Even a wicked person who has faith in Hashem will be surrounded with favor.
How can the words of the CHOVOS HALEVAVOS be reconciled with the YALKUT SHIMONI?