Looking at the currently available evidence, I’d say that it’s highly likely that Russian forces, either air defences, or fighter patrols or escorts, mistakenly shot down Azerbaijan Airlines Flight 8243. GPS jamming is not the cause of this. There are entry and exit holes in the fuselage even visible from inside of the aircraft, part of the left wing was missing, and the vertical stabiliser was shredded like a piece of Swiss cheese. It was likely hit by a missile (not an oxygen canister or internal bomb, those are very unlikely to end up inside the vertical stabiliser), and only Russia has the capabilities in that location. They were either aiming at a Ukrainian drone close to the civilian airliner and the missile unintentionally tracked the civilian airliner or exploded in close proximity to it, or there was a case of mistaken identity and the civilian airliner was shot at directly. The detour could just be the pilots trying to regain control after the aircraft was hit, with damaged control surfaces and relying on the engine power to keep the aircraft stable and controllable.
The Azerbaijan Airlines flight was operating near the Caspian Sea, and Russian bombers often perform cruise missile launch maneuveres over the Caspian Sea, and will be accompanied by fighter escorts and patrols. A Russian cruise missile attack on Ukraine took place shortly beforehand.
Then there’s the fact that Grozny was under attack by Ukrainian UAVs at the time, including remotely piloted Cessna aircraft filled with explosives, potentially giving out civilian IFF codes, and Russian air defences were active.
This incident, combined with the US Navy shooting down their own F/A-18F aircraft, and narrowly missing another, with the use of SM-2 surface to air missiles equipped with a terminal infrared (IR) heat seeker according to sources in the US Navy that gave information to US news outlets, should show that IFF is not some magic forcefield that prevents the shoot down of friendly or civilian aircraft, and that missiles can easily track unintended targets with improper fire control. I would do a write up on how the different types of missiles work and their guidance with regards to that, but that would take a lot of time, so I’ll just link this write-up on the subject here. It’s a good summary regardless of the source.
I would say that the deviation could be explained be the pilots trying to regain some control over the aircraft after being hit, or simply turning away from their intended destination of Grozny after being fired upon. I don’t know if it would be possible for the pilots to make any kind of controlled turn given their situation (damaged/inoperable control surfaces and relying on the engines to control the aircraft) without losing a significant amount of altitude, potentially over the Caspian Sea. So they could just be focusing on keeping it straight and level for as long as possible, until they were over land again or lost too much altitude to continue flying and were forced into a crash landing. Either way the pilots are heroes for managing to crash land in such a way that some people could survive. Landing this and coming out with the end result of 20+ survivors is incredible.