It should be fixed with this change:
https://github.com/discourse/discourse/commit/e7fc2d46597c0cf4441bea070dc2f9610e8ca82b