I have existing entity in datastore. I can find it Admin Console by attribute query e.g.:
SELECT * FROM UserEntry where email = 'user@mail.com'
and also query it by encoded key string, e.g.:
SELECT * FROM UserEntry where __key__ = KEY('cy1hcHByIAsSCVVzZXJFbnRyeM')
However, when I query the entity by unencoded key, it is not found:
SELECT * where __key__ = KEY('UserEntry','user@mail.com')
From former queries I can verify that the key is correct and the same query works for other entities of the same type.
I experience the same behavior when I try to access the entity via JDO API:
pm.getObjectById(UserEntry.class, "user@mail.com");
This code results in following exception:
javax.jdo.JDOObjectNotFoundException: Could not retrieve entity of kind UserEntry with key UserEntry("user@mail.com")
How did this happen? How can I resolve this issue and avoid it in the future?
Off-line we discovered that the urlsafe key string encodes for a username with a space added, as if it encoded
KEY('UserEntry','user@mail.com '). That seems an input validation bug in the program.