-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datastore Key's reference is missing location identifier in app argument in to_legacy_urlsafe() #3597
Comments
@michaelenglo I'll let @jonparrott handle this. I voiced this concern when writing the original PR and he said we shouldn't worry about it. I would suggest that you rely on |
As for sending a PR, there is no "right" way to fix this. The |
Because there's no "right" way to fix this, I think we should just document that the string returned by our |
I am a bit concerned about this because urlsafe play an important role in our app. Currently in the implementation of our Document Control app, every document file has its information (in datastore), and its blob (in cloud storage). The way we name each document is by its urlsafe key (since we thought it's always unique, we decided to use it instead of creating app-specific identifier). Now, If we cannot guarantee that both services in Std and Flex generate the same urlsafe key consistently, then there is a chance that in the future we can have corrupted files lost in the database. Is using urlsafe as unique name for objects something that we should avoid? If yes, then what is the proper way for mapping entities to blob objects in cloud storage? And I wonder why if NDB has a method to create a ursafe key that is identical from the one in Datastore, what prevents the Client Library from having one? |
@michaelenglo You can get around this by just using the same identifier here that is using in App Engine standard. It's fairly like your application uses |
|
Hey @michaelenglo, |
@michaelenglo And if you want truly identical behavior in your application, you should determine which prefix your app uses (it's almost certainly
via |
Where can I get the location prefix of my app? Is there a way to programmatically find it? Or is there a list published anywhere? |
@dhermes I put this as a new issue because I thought people might have a problem with this too. Please feel free to edit/remove this issue if it is not appropriate to put it here.
I was running
pip install --upgrade google-cloud-datastore
to get latest version that has thekey.to_legacy_urlsafe()
implemented in #3491. I tested the method and I found out that the urlsafe generated from the method is still not the same as datastore's urlsafe.I have implemented my own function to generate the urlsafe key before the update was released and so far it worked properly for me (I can share my code if anybody wants). So I compared my function with the to_legacy_urlsafe and I found the problem:
In the app argument, the location identifier is missing unlike in my function where I concatenated the "s~" at the beginning of the string. I think this is the cause of the problem why it was not getting the urlsafe correct, although I don't understand why it needs the location identifier in front of the project name in the first place.
Do you think I should send a PR to fix this?
The text was updated successfully, but these errors were encountered: