in the absence of a fix to the bug report that @snakecharmerb found, could you not base64 decode the string and tease out the pieces that you need to construct a Key via the Key.newBuilder
method?
Certainly not ideal, but would get you around the issue.
We have some URL-safe Datastore Keys that were created using in the AppEngine API, for example agx0cmFkZW9zLXRlc3RyHQsSEHVzZXIvTGVnYWxFbnRpdHkYgICAgIDu1AkM
These are parsed correctly in the AppEngine API, using com.google.appengine.api.datastore.KeyFactory.stringToKey(key)
However, in the Google Cloud API, com.google.cloud.datastore.Key.fromUrlSafe(key)
always generates a parsing error as below.
Perhaps the URL-Safe string formats of the Google Cloud API was changed incompatibly, but we do need to be able to parse and also to generate the old format.
Ultimately this is a string-parsing task with no deep dependency on the libraries, so it should be possible to do with a simple code snippet.
How can we parse and generate such key strings using the Google Cloud API?
java.lang.IllegalArgumentException: Could not parse key
at com.google.cloud.datastore.Key.fromUrlSafe(Key.java:205)
...
Caused by: com.google.protobuf.TextFormat$ParseException: 1:61: Expected "{".
at com.google.protobuf.TextFormat$Tokenizer.parseException(TextFormat.java:1064)
at com.google.protobuf.TextFormat$Tokenizer.consume(TextFormat.java:750)
at com.google.protobuf.TextFormat$Parser.skipFieldMessage(TextFormat.java:1770)
at com.google.protobuf.TextFormat$Parser.mergeField(TextFormat.java:1528)
at com.google.protobuf.TextFormat$Parser.mergeField(TextFormat.java:1439)
at com.google.protobuf.TextFormat$Parser.merge(TextFormat.java:1423)
at com.google.protobuf.TextFormat$Parser.merge(TextFormat.java:1342)
at com.google.protobuf.TextFormat.merge(TextFormat.java:1221)
at com.google.cloud.datastore.Key.fromUrlSafe(Key.java:200)
... 1 more