Does a treaty with an idolatrous, foreign power bind the king who made it? The answer is ‘yes’ if the oath was made before God:
Ezekiel 17:19 So this is what the Sovereign Lord says: As surely as I live, I will punish him for breaking my covenant and disregarding the solemn oath he made in my name.
It seems that even a political agreement can’t be cast as ‘just politics’, a game in which an agreement has no more value than the paper it’s written on.
In this case, this arrangement had been set up by God to both discipline Judah (Israel) for her sins and protect her.
Instead, the last king of Judah tried to save himself, breaking one part of the Law about keeping oaths (how could a king unvow that vow?) and another in turning to Egypt for help (something that was generally forbidden).