ui: avoid needless casting to a str
In many cases, we don't need to cast to a str because the object will be cast when it is eventually written. As part of testing this, I added some code to raise exceptions when a non-str was passed in and wasn't able to trigger it. i.e. we're already passing str into this function everywhere, so the casting isn't necessary.