I think this should fix it:
https://github.com/discourse/discourse/commit/c5c443fda3d7001e2d0947506b06de307fb0af24