Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.
This repository was archived by the owner on May 6, 2026. It is now read-only.

urlsafe ndb key is different than datastore admin #264

Description

@chmoder

entity.key.urlsafe does not return the same key as shown in google cloud datastore admin.
Below is an example of how this NDB library does read and get the same entity using the two different keys. user_b_key below , is the url-safe key show in google cloud datastore. user_a_key is the key generated by entity.urlsafe() for both entities (technically the same entity).

The key generated by entity.urlsafe() does not work on google cloud datastore console to look up an entity by key. There is an error saying *the project some-project does not exist. Except the first two letters of the project (app) name are chopped off.

Environment details

  1. Datastore and ndb
  2. OS X
  3. python 3.7.3
  4. google-cloud-datastore 1.10.0

Steps to reproduce

  1. save an entity (with app engine standard v1 or v2 + this ndb lib)
  2. get (1) entity
  3. invoke urlsafe on (2) entity

Code example

from google.cloud import ndb
user_a_key = ndb.Key(urlsafe='agpjc2dhcGktZGV2chELEgRVc2VyGICAgIDk9dEIDKIBBGF1dGg')
user_a = user_a_key.get()
print(user_a.key.urlsafe())
user_b_key = ndb.Key(urlsafe='agxzfmNzZ2FwaS1kZXZyEQsSBFVzZXIYgICAgOT10QgMogEEYXV0aA')
user_b = user_b_key.get()
print(user_b.key.urlsafe())

Stack trace

n/a

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.status: investigatingThe issue is under investigation, which is determined to be non-trivial.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions