nodejs-datastore icon indicating copy to clipboard operation
nodejs-datastore copied to clipboard

Generated string for keyToLegacyUrlSafe using namespace undefined vs empty string

Open bogdan-nourescu opened this issue 1 year ago • 0 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

  1. Is this a client library issue or a product issue? Yes, i believe its a client library issue (@google-cloud/datastore)

  2. Did someone already solve this? no other issues found/resolved

  3. Do you have a support contract? no

If the support paths suggested above still do not result in a resolution, please provide the following details.

Environment details

  • OS: Windows
  • Node.js version: 18
  • npm version: 9.6.7
  • @google-cloud/datastore version: 8.7.0

Steps to reproduce

There is a difference between urlSafe keys generated using the empty string as a namespace and undefined as a namespace. The empty string one has a few letters extra at the end of the string.

const datastore = new Datastore({});
let hash1 = (await datastore.keyToLegacyUrlSafe(datastore.key({namespace:undefined,path: ["Kind", "name"]}), "e~"))
let hash2 = (await datastore.keyToLegacyUrlSafe(datastore.key({namespace:"",path: ["Kind", "name"]}), "e~"))
console.log(hash1, hash2)

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

bogdan-nourescu avatar Jul 10 '24 15:07 bogdan-nourescu