It was happening because of a bug. It’s fixed here:
https://github.com/discourse/discourse/pull/12819