Fixed #21497 -- Forced conversion to bytes for very long index names

Includes a regression test.