You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 6, 2026. It is now read-only.
If an entity is deleted, the context cache will store a None value. Then if a query is executed in the same context which will return the deleted entity because the datastore is not yet consistent, the underlying datastore query will return the value, but the cloud ndb library will find None in the context cache and return it in the results. The None value should not be returned to the client (this is a regression from the original ndb library).
Versions
google-cloud-ndb==1.7.1
Steps to Reproduce
It's slightly non-trivial due to the variable timing of consistency but the example code illustrates what triggers the problem.
Put a model object into the datastore
Ensure that the datastore is consistent
In the same context do the following:
Delete the object
Query the object before the datastore is consistent
Code Example
test_key = TestObject(val='abc').put()
# assume consistency here...
test_key.delete() # this will put the None value in the context cache
# assume eventual-consistency here, such that the datastore will still return the object in the query...
results = list(TestObject.query().filter(TestQuery.val=='abc')
#results will be [None] instead of []
If an entity is deleted, the context cache will store a None value. Then if a query is executed in the same context which will return the deleted entity because the datastore is not yet consistent, the underlying datastore query will return the value, but the cloud ndb library will find None in the context cache and return it in the results. The None value should not be returned to the client (this is a regression from the original ndb library).
Versions
google-cloud-ndb==1.7.1
Steps to Reproduce
It's slightly non-trivial due to the variable timing of consistency but the example code illustrates what triggers the problem.
Code Example