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

FieldPath only escapes the first \ and '`', resulting in INVALID_ARGUMENT response #2019

Open
pavadeli opened this issue Mar 15, 2024 · 1 comment
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore 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

@pavadeli
Copy link

Environment details

  • OS: MacOS
  • Node.js version: latest
  • npm version: latest
  • @google-cloud/firestore version: v7.3.1

Steps to reproduce

  1. Try to use a FieldPath with multiple backslashes or backtick, for example:

    query.where(new FieldPath('containing multiple `` or backslashes \\\\'), '==', 0)
  2. Run the query, then you get: 3 INVALID_ARGUMENT: Invalid property path ...

This is because of the use of replace in the following line:

: '`' + str.replace('\\', '\\\\').replace('`', '\\`') + '`';

The replace() method only replaces the first occurence of the given pattern (see MDN for more info).

@pavadeli pavadeli 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 Mar 15, 2024
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Mar 15, 2024
@pavadeli pavadeli changed the title FieldPath only escapes the first \ and ` ``, resulting in INVALID_ARGUMENT response FieldPath only escapes the first \ and **`**, resulting in INVALID_ARGUMENT response Mar 15, 2024
@pavadeli pavadeli changed the title FieldPath only escapes the first \ and **`**, resulting in INVALID_ARGUMENT response FieldPath only escapes the first \ and `, resulting in INVALID_ARGUMENT response Mar 15, 2024
@pavadeli pavadeli changed the title FieldPath only escapes the first \ and `, resulting in INVALID_ARGUMENT response FieldPath only escapes the first \ and '`', resulting in INVALID_ARGUMENT response Mar 15, 2024
@ehsannas ehsannas self-assigned this Mar 18, 2024
@ehsannas
Copy link
Contributor

Thanks for reporting @pavadeli . I'll look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore 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