Our Gemara at the end of Amud Beis tells us that Rabbi Yehuda holds that an oath made in public cannot be annulled . His proof is from the Gibeonites, who fooled Yehoshua into thinking they were foreigners and refugees from a distant land, leading them to make an oath and treaty with them (see Yehoshua chapter 9). Even though it was done under false pretenses, at least according to Rabbi Yehuda, the main reason why Yehoshua honored the oath is that it was public.
Related to this topic, Rabbi Elazar Fleckless’ Teshuva Meahava wrote a responsa regarding the status of an oath with a non-Jew.
(Rav Fleckless lived from 1754-1826 and was a loyal disciple of the Noda BeYehuda. Interestingly, in his second introduction, Rav Fleckless wrote that he named the Sefer Teshuva MeAhava because it was written with no financial motive but rather love of providing a correct response to halakhic quandaries.)
In responsa I:26 he responds to a petitioner who asks, since we see that many laws are different between Jew and non-Jew, such as l’shon hara and usury, is an oath between a Jew and non-Jew binding to the same degree as an oath made Jew to Jew?
Rav Fleckless rules that there is no difference and goes on to discuss the severity of an oath and its status as a fundamental law. He says that faithfulness in oaths is the bedrock of civilized society, and he says we see in the early narratives in Bereishis that Abrahamic and non-Abrahamic alike treated oaths and vows as sacred. Avimelech, Esav and even the thief and trickster, Lavan, treated an oath as inviolate. He further states that this is why the Gemara Shavuos (38b) says that the entire world shook when Hashem said, “Do not bear my name falsely.” Why for this commandment more than any of the other commandments? And why the entire world? The Gemara means to say that the entire world depends on the ability for humans to honor their word and their agreements. Without this basic trust, society would collapse. Think about it, rules of engagements in war and diplomacy must be honored universally, otherwise we risk complete savagery.
In regard to oaths to non-Jews, Rav Fleckless says that when Yehoshua’s spies swore to Rachav to save her and her family (Yehoshua chapters 2 and 6), they had every possible reason to rationalize bypassing the oath. a) The two spies swore. Is the entire people of Israel obligated to confirm and uphold the oath? b) The spies themselves were coerced at the time. Their lives were in danger if they did not heed her. Had they not wanted to swear, she would have gone and disclosed that spies were afoot, and they would have been sentenced to death. c) Their oath does not take effect when there is an overriding mitzvah, which itself is an oath to God: “you shall not let a soul remain alive. You must doom them to destruction.” d) She, her family, and all those who accompanied her were idolaters. e) The seven nations were wicked and sinful against God, and they perpetrated all manner of abomination that God hated. Therefore, we see five conclusions: a) An oath is very severe, even if sworn to a gentile, b) Even to wicked people who perpetrate abominations. c) Even if it cancels the mitzvah “you shall not let a soul remain alive.” d) There is no claim of coercion or disclaimer against an oath. e) There is a duty for every Jew to try his best to make sure that his comrade and ally does not transgress with a false oath.
One should not insist that the story of Rachav is different because she benefitted Israel greatly with her kindness toward the two spies, and had they not upheld the oath, they would have replaced good with evil, and there is no worse trait than ingratitude. Because we see from the story of the Gibeonites and Yehoshua that even though they were deceitful to the leaders of the people, and misled them to swear and make a treaty with them, the Israelites did not kill them. This must be because, after all, the leaders of the people stop swore to them. This is irrefutable proof that a Jewish man may not swear falsely to any man on this earth, regardless of nation or language. There is no dispensation for this whatsoever. Even if he was tricked and duped into swearing, there is no excuse in the world for swearing falsely.
(Another fascinating side point brought up in this Teshuva is about the provenance of the Zohar. The petitioner asked if there is a special reason to make an oath on the Zohar. To this point Rav Fleckless responds:
…The Zohar is entirely holy. But I hereby swear by God’s Torah that there are mistakes and forgeries that have been added to the Zohar, and that one page of the Talmud Bavli, the debates of Abaye and Rava, is holier than the entire Zohar.
Behold, if the talmudic sages say of a beraisa, that if it was not taught by R. Hiya and R. Oshaya, we do not know whether it is correct or corrupted. Surely then, this book [the Zohar] was not taught by R. Hiya and R. Oshaya, because every generation, from the beginning, made no mention of the Zohar at all, neither awake nor in a dream. If it is true that this work is by the tanna R. Shimon b. Yohai, from whom R. Yehuda the Nasi received [the Torah], among others, as explained in Maimonides’s introduction to Mishneh Torah, how could he not mention this book in his work, the six orders of the Mishna, or anywhere else? So too, R. Yohanan, who composed the Talmud Yerushalmi, does not mention it anywhere. Ravina and R. Ashi, who composed the Talmud Bavli a century after the Talmud Yerushalmi was composed, and who were at the end of the Amoraic period, make no allusion to the Zohar anywhere in the Talmud. Rabban bar Nahmani, who composed Midrash Rabbah, Midrash Shoher Tov, and many similar works, did not mention the work by R. Shimon b. Yohai. The Savoraic rabbis, the Geonim, Rif, Maimonides, Rashi, the Tosafists, Nachmanides, Rashba, Rosh, Tur, and Yalkut Shimoni—which compiled and gathered all of the midrashim, halakhic midrashim, and beraisos—did not know or see anything of it, until some three hundred years ago when they said they discovered it.
Yet at what gathering was it accepted collectively, as were the Bavli and Yerushalmi? Thus states Maimonides in his introduction to Mishneh Torah: "But whatever is in the Talmud Bavli is binding on all of the people of Israel; and every city and town must practice all the practices instituted by the talmudic sages and follow their enactments, for everything in the Talmud received the assent of all of Israel…" I do not, God forbid, cast aspersions upon or tarnish the honor of the godly tanna R. Shimon b. Yohai, for he was one of the most sublime of the pious sages. Rather, I say that [the Zohar] is not sealed with the imprimatur of R. Shimon b. Yohai. Anyone with half a brain can say that, because the book of Zohar mentions several tanna’im and amora’im who lived many years after R. Shimon b. Yohai. I have written on this at length elsewhere, based on sages and their books, as explained in our master R. Yaakov Emden’s Sefer Mitpachas Hasoferim, in which he decreed that the hands of forgers have been applied to it, and he suspected the sage R. Moshe de Leon.
You can find more information about the provenance of the Zohar in Psychology of the Daf Beitzah 4, where we quote Rav Emden.)