Search code examples
google-app-enginegoogle-cloud-platformgoogle-cloud-datastore

GAE Datastore "java.lang.IllegalArgumentException: Property `${property}' contains an invalid nested entity."


Started receiving an error for the past couple days for persisting nested map structure as an Embedded entity. It was working early without any problem.

java.lang.IllegalArgumentException: Property metrics contains an invalid nested entity.
    at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:49)
    at com.google.appengine.api.datastore.DatastoreApiHelper$1.convertException(DatastoreApiHelper.java:127)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:97)
    at com.google.appengine.api.datastore.Batcher$ReorderingMultiFuture.get(Batcher.java:115)
    at com.google.appengine.api.datastore.FutureHelper$TxnAwareFuture.get(FutureHelper.java:171)
    at com.googlecode.objectify.cache.TriggerFuture.get(TriggerFuture.java:100)
    at com.googlecode.objectify.impl.ResultAdapter.now(ResultAdapter.java:34)

Also already that property unindexed. Technically it should ignore the limit of 1500 bytes. I think they made some changes to restrict this.

This error is not documented anywhere.


Solution

  • Keys with dots cannot be used in embedded maps because they have a unique meaning in the new API. If you must have dots in your keys, you can escape them using an @Stringify Stringifier.

    Consequently, if you insist on using embedded maps, sanitize to prevent such exceptions.

    Found the reason here: https://github.com/objectify/objectify/wiki/UpgradeVersion5ToVersion6