What is the failure mode of a solar panel?

Reading here and a couple other places makes it sound like solar panel degradation varies widely. Manufacturing origin doesn't appear to be correlated to longevity or if it is, it may be opposite what we expect (China appears to do well). The general gist is that you'll lose a fraction of a percent every year on average. It's likely due to high energy photons slightly changing the structure over time. Weathering is also a concern. Wind-blown sand scratching the surface and dust blocking light are two other ways cells degrade. Most solar installations appear to be able to handle 20-40 years of use without issue, but some don't appear to handle thermal cycling well. In that case, you can have catastrophic failure of one or many cells causing poor solder bonds to break, delamination to occur, or entire cells to crack. Corrosion of the cell and connectors could be another late game failure mode.

I think more of a concern than the cells degrading is the supporting electronics (inverter) dying. The cost of installing a solar installation these days is largely being determined by peripherals rather than the panels themselves. Power electronics to support the system and their failure mode is really what I would be researching if I were in your shoes as I believe the likelihood of catastrophic failure there is much more likely in a much shorter timeframe.

This looks to give a great rundown of many manufacturers and their lifetimes. I've included a diagram from there below: enter image description here

Just to address the "last essentially forever" part. Unlike some semiconductor devices which can work for half a century or more, solar panels don't get the privilege to be used indoors. This means they will suffer from UV and corrosion and will have a limited lifespan.

It also should be noted that mass-produced solar panels are relatively new, which means their lifespan figures (which are typically around 20-30 years) are only an extrapolation from accelerated aging tests and limited statistical data from panels installed 30 years ago. This is important to understand if you're about to make an investment decision based on this data. I would be extremely wary of investing in solar panels if my profits were a bet on whether they will last for 20 years.