You assume that the head of Amazon wouldn't want to hear personally about a lot of very bad code being casually tolerated over a long period of time under his watch. I find that baffling. Ignoring something like that is not very "day one." (To use Bezos' mantra.) Amazon also have a board who are probably competent and interested in the company not ____ing up. That a complaint might get lost in the shuffle or noise of a big company doesn't mean it shouldn't be made; but it may mean it shouldn't be made just once.
Yes, there are bosses who don't want awkward info. At NeXT, Jobs didn't want to know (in those days) he just wanted stuff done, so even though his N.A. managers pretty much knew the European manager was not telling the truth about his spectacular sales success they didn't make sure the information got to Jobs, since he didn't seem to want it. Worse, the European staff regulars who were asked to do the dirty work and did know there was a big problem (if only because they say huge stacks of computers piling up in warehouses collecting dust, say) didn't see fit to inform Jobs. The company failed because the European manager was committing massive fraud to fake sales. (Without that, it might have failed for other reasons but that's why it failed.)
But Jobs was unusual in more than one way (and did learn that lesson.) Why on God's earth assume that upper management never wants bad news? The truth is that upper management is often very well-aware that frequently middle managers, and low-level managers tend to serve themselves even to the point of putting the whole company at risk and see it as a big part of their job to prevent that; but they don't know how and where until they're told. The fault with upper management is more usually that they assume that some floor employee would have knocked on their door if anything odd was going on; but as the discussion here shows so vividly, that's by no means always true.
Yup, again, there are some bad bosses who are going to drive their companies into the ground if they can, but it's a dereliction of duty to assume that. If you're taking money from a corporation, twiddling your thumbs while it starts to goes into a steep dive, or continues one, isn't ethical.
Of course, if you go over a boss's head, you absolutely have to have done your homework, and to be right. It's not something to be done impulsively, but it's a duty.
Books such as "The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers" by Ben Horowitz take great pains to convince those heading or managing businesses to make sure every employee takes responsibility for what happens to the company as a whole (from the employee's action and inaction) if that boss wants their company to survive. I could name many others.