@jlc Thanks for the detailed report. This has been fixed.
https://github.com/discourse/discourse/pull/20600