For context, I first heard this idiom used some months ago in my workplace which deals with cinema and storytelling, so there's a chance it might be a trope and not a colloquial idiom or similar. The structure is "an X Y", like "a Pyrrhic victory" or "a dead duck."
It's meant to describe an effort where there are a string of mistakes, some of which compound into another - "a series of unfortunate events" - but at the end of it all, the job is still complete, or the victory is still had. The tonality is neutral to positive. A friend suggested "by the skin of one's teeth" which is similar but it doesn't hit the structure and the tonality is more... earnest? Whereas the one I'm thinking of is almost comical.
I'm sure you lot get questions like these all the time so I sincerely appreciate any and all help! Thank you!