Varstrings are terminated with a character with value \0, and cause issues if they are used as keyed fields in an index.
Two possible guesses at what is going on. Maybe the data after the trailing 0 is uninitialized, and is sorted by the strings, but not if you include the data following the trailing 0. Or it could be that when searching for elements in the key that uninitialized data after the 0 is causing grief.
Either way we should report an error if you try and use them in the keyed portion of an index – since they’re likely to cause problems and don't provide any benefit. (If you really need an exact string match including length, match a string<n> and store a separate length..)