Fix error message when the key is invalid