Michael Flynn was supposed to skate.

Everyone in Washington knew that.

He had pleaded guilty to lying to the FBI, had cooperated with Bob Mueller, both sides agreed he shouldn't get jail time, and the sentencing hearing was just a formality.

Until it wasn't.

The judge made clear he was going to put Flynn behind bars, and at his strong suggestion, President Trump's former national security adviser asked that his sentencing be delayed.

It's a case study in a high-risk defense tactic that backfired. Since Flynn had already admitted lying to FBI investigators, federal judge Emmet Sullivan was clearly ticked off at a defense memo suggesting that the bureau set him up by entrapping him. It's never a good day in court when the judge tells the defendant he can't hide his "disgust" and that "arguably you sold your country out."

But it's an even more illuminating lesson in how Beltway groupthink often turns out to be wrong. In the nonstop cable coverage during the hearing, many journalists were virtually certain that Flynn would get no jail time. And even on left-leaning channels, there was a sympathetic view that the retired lieutenant general had served his country and had earned leniency by cooperating early with prosecutors.

What happened is that almost everyone developed a certain tunnel vision of what should happen and what would happen — so it came as a shock when the judge, a Reagan appointee, weighed in with a harshly different view.

Since the sentencing guidelines for Flynn's crime called for zero to six months, it wasn't a huge stretch to believe that Flynn would either get no jail time or minimal jail time, especially with Mueller's office pushing for the most lenient outcome.

But in recent days, Flynn's advocates and allies began framing a new argument — embraced by conservative media, including some Fox commentators — that he really wasn't guilty at all. In fact, they said, he had been railroaded.

A Wall Street Journal editorial was titled "The Flynn Entrapment." Fox's Judge Jeanine Pirro said FBI officials "didn't want the truth. They wanted to take down a bit player to get to the big player." Outgoing House Intelligence Committee Chairman Devin Nunes told Fox it was "nothing short of entrapment" and this is "an embarrassment to our country."

Yet the idea that Flynn was "ambushed" — to use Sarah Sanders' word — requires one to believe that the former head of the Defense Intelligence Agency had no idea he needed to tell the truth to FBI agents about telling a Russian diplomat the U.S. might ease sanctions against Moscow.

Here again, the process-oriented press corps focused just on the lack of candor with the FBI, rather than the fact that Flynn was engaging in back-channel discussions with the Russians at the end of the Obama administration. (He also lied to the White House.) And Flynn served as an unregistered foreign agent for Turkey, though he wasn't charged with that. That's why Sullivan asked prosecutors whether they had considered charging Flynn with treason.

There's no evidence of treason, but Sullivan's blistering rebuke made clear he was angry that Flynn was kinda sorta blaming the FBI and repeatedly asked him to affirm that he knew lying to the bureau is a crime.

Maybe the delay will help Mike Flynn in the end. But the media should be careful about being so focused on legal arguments and political spin that they lose sight of the big picture.