It must be the additional complexity of the data you’ve got that’s causing the bug to appear, whilst my trivial example DB doesn’t trip it up.
Since I can’t reproduce it myself, I’ve had to take a bit of a speculative bug fix attempt in Hunt-and-kill a few more mis-encoded params · discourse/discourse@67882ec · GitHub; please let me know if it does/doesn’t work for you. I think we’re going to have to do a larger and more comprehensive fix for this, along the lines of this initializer; playing whack-a-mole with parameter encodings one-by-one seems like a good way to go prematurely bald.