Skip to content
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

Generated string for keyToLegacyUrlSafe using namespace undefined vs empty string #1260

Closed
bogdan-nourescu opened this issue Jul 10, 2024 · 1 comment
Assignees
Labels
api: datastore Issues related to the googleapis/nodejs-datastore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@bogdan-nourescu
Copy link

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 bogdan-nourescu added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 10, 2024
@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/nodejs-datastore API. label Jul 10, 2024
@danieljbruce
Copy link
Contributor

This behaviour is expected. We want these two hashes to be different because we want keyFromLegacyUrlsafe to be the inverse of keyToLegacyUrlsafe so every input of keyToLegacyUrlsafe should map to a unique value.

That said, we will take an action item to ensure keyToLegacyUrlsafe and keyFromLegacyUrlsafe are inverses of one another. Please reopen this issue if you have any more questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/nodejs-datastore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants