Usually, the text editor Geany opens, but sometimes another wrong app opens
Some file extensions open correctly, but not all. PDFs open with Geany, for example. This seems to change over time because PDFs used to work while others didn't.
Files open properly from Caja. xdg-mime query filetype returns application/pdf for a PDF file. Update: But query default returns nothing.
This duplicates two previous questions from me. One didn't get a good answer, and the other answered one of my questions.
I'd suggest to try a simple method first. I.e. right click on a file of desired type, say, .pdf. Select menu entry Open with > Another Application and select the proper application. Ensure that Remember this application for ... files checkbox is selected and press Open button.
The files open fine from inside Caja. It is the Recent Files that won't open correctly. I did check and see precisely what you have for PDF files that Atril is the viewer to open.
What sets the mime-type? Both files were downloaded using the browser although the 2nd PDF was awhile ago.
Update:
I downloaded a PDF. Caja properties show it as an "application/pdf" but opens in Recent as an "octet-stream." Opening it from Caja works, and then opening it from Recent works.