Sefer Chasidim Siman 645
Can copy this into an AI, or connect the whole library to your assistant. For deeper learning, you can directly use the original seforim, sites, and apps.
אדם שמחשב לעשות מצוה והיא אינה מצוה אלא עבירה היא ועשאתה כי לא היה לו ממי לשאול מקבל שכר כבנות לוט אבל אם היה לו ממי לשאול ולא שאל נענש כעוזיהו וכיפתח שלא רצה לשאול על נדרו לפנחס להציל בתו:
Medieval Jewish mysticism, translated by Sholom Alchanan Singer. Northbrook, Ill. Whitehall Co., 1971
A man who sought to perform a mitzvah and it turned out to be a transgression and the case is such that he didn't have anyone to take counsel with - gets a reward like Lot's daughters, however if there was someone to consult and he did not - he gets punished like Uziyahu and Yiftach who was unwilling to inquire as regards his vow in order to rescue his daughter.