Here’s the proper fix:
https://github.com/discourse/discourse/commit/005b8bf7c3a257f1e531965e9a19bc92b2f0a587