It's a complicated one, but legally it's a civil contract; if the Ukrainian government decided to stop the gas flowing, both Gazprom and all the companies "downstream" would be in their rights to sue for breach of contract and/or causing gas shortages, costing the Ukrainian government billions.
And you could wonder why they signed the contract anyway given Russia invaded/annexed Crimea 5 years prior, but, it's a lot of money, and at the time it was still considered a civil contract I presume.
Ultimately the general public is capricious in its beliefs: cutting the gas off and causing energy prices to spike in Europe means someone will call for the head of whoever's nearest to blame.
Ukraine also was deliberately not targeting Russian oil assets earlier at the request of the US for economic reasons - though I'd say recent American political history shows what a mistake that is.
There's been a change in the administration (and therefore strategy) of the USA, which changed the way the game was being played.
I think that (almost) everyone that has actual skin in that particular game also knows that none of the agreements that any of them make are reliable for a long term (I saw recently that the Ukranians gave up the Nukes they had at the behest of the US government, and on the.. I don't know if it was explicit, implicit, or just assumed.. understanding that the USA would provide some sort of security guarantee (which, of course, has never materialised)
They also had about as much latitude to keep those nukes as Germany would. Some people act like Ukraine owned and controlled the nukes and had a meaningful choice. They never did.
It wasnt given security guarantees either, it was given a promise that its independence wouldnt be infringed upon in a memorandum (not in a treaty).
As the Americans stated themselves in 2013 when they violated their promises within the Budapest memorandum, that memorandum wasnt legally binding. It was treated like toilet paper first by the Americans in 2014 and subsequently the Russians in 2014.
Whereas try collecting a debt from a nuclear power who's uninterested in paying it.
Tell it to the people caterwauling about the budapest memorandum, not me.
>it's extremely obvious that handing back the Soviet nukes they had possession of was a mistake.
It's the furthest possible thing from obvious. Ukraine couldn't maintain the weapons and was in desperate need of economic assistance it would never have gotten if it kept the nukes.
Moreover, if they tried to keep them Russia would likely just have taken them or rendered them unusable by force and we likely would have supported that.
There was absolutely no way for Ukraine to keep the nukes, not only because both the West and the East/Russia were against it but more importantly, the powers that be in Ukraine had other plans.
Also, I wouldn't comment on a fait accompli unless doing so pointed to information important for understanding today's realities.