Thank you all for cracking this mystery, here’s a PR to fix the bug:
https://github.com/discourse/discourse/pull/30634