The encoder can always generate the code for a literal pixel if the required colour is not found in the index.
TLDR is hash collisions are an explicit part of the format. Encode and Decode are both specified to use the same hash function, so the hash collisions will all cancel out.