Here’s a fix:
https://github.com/discourse/discourse/commit/d0a7f15764f8344e1f39a41624d77326990be5ed
Thanks @ondrej!