I read the Iranian air force relied heavily on Ukrainian aircraft industry to supply spares and other relatively high tech goods that couldn't be produced domestically, and that after the Americans killed Qasem Soleimani, which resulted in Iranians shooting down a civilian Ukrainian airliner, brainlet ideologues took over and replaced realpolitik with emotion driven nonsense like jumping on the sinking ship of the Russian invasion and supplying armaments and machine goods
in return for nothing.
Someone please fact check me on that.
Tl;dr:
In the past, its very difficult to separate out what was Moscow using Ukraine as their "I'M NOT TOUCHING YOU" cat's paw to fuck with the US, what was some guy who was a KGB General going off the reservation for their own payday, and how much was internally driven Ukrainian decisions (greed or geopolitical aims).
Ukraine did a lot of deals with a lot of whoever. The list was a lot of countries who bought Soviet equipment and needed help maintaining it or wanted to expand their arsenals or increase capabilites, and many of them were on a naughty list or two. What probably noone knows is how much was Ukrainian Greed and how much was Russia Puppeteering so the Kremlin could shrug and say "well, don't look at us, we didn't give Iran any missiles! We just didn't stop the independent nation of Ukraine from selling them, independently. Ok yes they did check with us, but we didn't say it was OK! we just didn't tell to stop because it
was allowed by the weapon licensing, we just didn't think they'd do it. We also notified you as soon as we realized it was a serious request and not just a manufacturing license question. We noticed this just about a week after it leaked to the media, which is pure coincidence".
Post-revolution Iran and the USSR have always been bedfellows. They are supporting Assad in Syria, both want US hegemony in the Middle East shattered. There is no question Iran was going to go Russia in this.
Iran doesn't have a lot of global friends, even fewer who would break UN arms sanctions and supply them with weapons or advanced tech. All those rocket parts and precision machined pipes shipped from Ukraine, but everyone knows they were sent by Russia. This is a good chunk of the reason Putin is so booty-blasted about his puppet getting coup'd - no more patsy to do Russia's sanctions-violating transfers.
Iran is making the same political calculus any smart person is making:
-Ukraine isn't a threat to Russia; Russian forces in Ukraine could be all wiped out and Russia's existence as a nation will not be under threat.
- conversely, win or lose in Ukraine, Russia's economy is going to be sanctions fucked for a long time.
- In the past, an economically hurting Russia has enabled sanction skirting to sanctions violating transfers to Iran to make payroll.
So since no matter the outcome Russia will exist after Ukraine, and be economically hurting, it makes sense to go full in bed. I mean, what is the worst going to happen to Iran if they do? Getting hit with Double Secret Sanctions? Additionally, Ukraine serves as the perfect chance to test their drones and shake down their drone production pipeline.
And after Ukraine is resolved?
Iran is owed by Russia, Big Time. And Russia has a lot of shit Iran wants.
From cheap grain, to steel, to oil refining technology... to modern aerospace components, advanced manufacturing, and nuclear experts.
The reason Turkey joined NATO was because the Soviet Union was at the time the existential threat to the Middle East, Following the Soviet invasion of Iran at the close of world War 2, the eruption of communist revolutions in Greece, and the bringing of Bulgaria and Romania, traditional Turkish enemies, into the Soviet fold.
Also because the USSR attempted to force the issue and underestimated Ataturk's ability to pick a competent successor. Inonu figured he could get away with NATO protections and privileges without having to pay too high of a cost, and figured correctly. Such as you Turkey and Greece, members of the same defensive alliance, going to war over Cyprus.
You lay out a good geopolitical case, but Erdoggydog going full good boy is a lot more simple than you expressed:
Putin doesn't have anything to offer anymore. The "2nd strongest army in the world" is shown to been the 3rd most powerful army in Ukraine. Russia is getting clowned by a country 1/4th its size, despite sharing a border. Russia has nothing to offer Turkey that Turkey can't get by backing Ukraine and cashing in Good Boy Points, and Turkey clearly has nothing to fear from Russia.
Additionally, by visibly going against Putin, Erdogan can use Putin's own bluster against him now: Turkey is standing up to Global Super Power Russia! Look! Mighty Russia doesn't dare do shit to shipping on the Black Sea as long as the Turkish Navy is providing escort. If Russia stronk, then how stronk must Turkey be if we're able to get away with this shit and Russia is cowering from the might of our ships and airforce?