-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make Key.toUrlSafe() consistent with the URL-safe key displayed in Google Cloud Datastore Console #1357
Comments
@sai-pullabhotla This is interesting. @aozarov any reason our |
I think that at the time that we provided the toUrlSafe it only worked for this library (there was no "standard"). I am glad to see that now there is and we should change the code to adopt it. |
Then @sai-pullabhotla thanks for bringing this up. I'll work on a fix soon. |
@eddavisson @pcostell can you guys help me understand how the base64 URL-safe key shown in the Cloud Console is computed? I expected it to match the following code: BaseEncoding.base64Url().omitPadding().encode(toPb().toByteArray()); But that is not the case. |
The base64 URL-safe key shown in the console only works with the App Engine client libraries. If you think it would be useful for it to provide a URL-safe key usable in the Google Cloud client libraries, please send feedback in the Cloud Console so it can get triaged by the right team. |
@pcostell Can't we generate this base64 URL-safe in Google Cloud? I think it would make sense for us to generate that value as it is used in AE libraries as well as in the Cloud console. |
Parsing and generating URL-Safe keys in the format of the Google App Engine API is essential for us to be able to use the Google Cloud API. |
@JoshuaFox Are you asking for compatibility within the library, or between GAE Standard API's / Cloud Console and this library? Also, how would it affect you if we changed the format generated by this library to be compatible with GAE Standard / Cloud Console? |
I'm not sure what "compatibility within the library" means, but of course I'd like all kinds of compatibility. Specifically, we have URL-Safe keys generated in the GAE API which need to be parsed into Key objects in Google Cloud API; and the Google Cloud API code has to be able to generate keys in the GAE URL-Safe string format. The Cloud Console is less important. In any case, we have since Jan 12 written code that digs into this format and does the above conversions, so for us it is less urgent; though still, this compatibility seems like an obvious requirement. |
@JoshuaFox What I'm trying to ask is, if we fix (ie. change the current behavior of the google-cloud API) to match what the GAE API does, would it break your app? |
I don't think it would break my app. |
@garrettjonesgoogle I think we should fix it, and the sooner, the better. (ie. before GA) |
@jabubake PTAL - you might wish to inquire / make sure that that thing your working on is compatible in this. |
|
Note - we should rename the existing Alternatively, but equally bad, we should create |
Maybe: create |
Since we will be adding methods instead of changing them, this isn't a breaking change any more. |
There has been some offline discussion and it doesn't seem like this can be fixed for GA, and might not be able to be fixed at all. |
It turns out that replicating the base 64 format of the cloud console in open source isn't possible right now; it requires a proto that isn't open source, and an app id that isn't available in the client library context. The solution is probably for cloud console to produce an alternative base 64 format that the client library can reproduce. |
My requirement was for comparability between Datastore Cloud API and Datastore GAE API; the Cloud Console (the GUI) is less relevant. |
@JoshuaFox ok, but the issue is the same anyway, right? |
I don't necessarily know the implementation details, but if the Cloud Console value is generated by the GAE API; in contrast to the Cloud API; then yes. |
Is there any plan to add implementation comparable to GAE API? |
@garrettjonesgoogle have you had a chance to check if Go can achieve this compatibility why Java cannot? |
Theoretically Java could, it would just require duplicating code instead of reusing it. |
This has been added to our feature backlog: https://github.com/GoogleCloudPlatform/google-cloud-java/wiki/Feature-backlog . This issue will be closed but is linked in the backlog and can continue to be used for comment and discussion. |
How is the status on this? |
…oogleapis#725) Source-Link: googleapis/synthtool@e122cb0 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:387835a1375a0049ec44e02542c844302854c732d8291bdf8e472c0ff70a8f67
Source-Link: googleapis/synthtool@e122cb0 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:387835a1375a0049ec44e02542c844302854c732d8291bdf8e472c0ff70a8f67
The
Key.toUrlSafe()
returns a URL encoded (similar toURLEncoder.encode
) version of the key like the one below:partition_id+%7B%0A++project_id%3A+%22my-project%22%0A++namespace_id%3A+%22MyNamespace%22%0A%7D%0Apath+%7B%0A++kind%3A+%22MyEntity%22%0A++name%3A+%22MyKey%22%0A%7D%0A
The Google Cloud Datastore Console displays a Base64 encoded version of the key, which looks something like -
agVoZWxsb3IPCxIHQWNjb3VudBiZiwIM
The Console allows filtering on key by URL-safe key, which works fine if I use the URL-safe value displayed by the GCD Console, but does not work when using the value returned from
Key.toUrlSafe()
.The Console Documentation states that -
So, the client libraries are expected to match with the Base64 version? Nonetheless, it would be nice to have the client libraries and Console in sync to help with crosschecking/debugging purposes.
The text was updated successfully, but these errors were encountered: