firebase / firebase/firebase-js-sdk

get() in security rules is bugged

Open
#3,908 2 comments 0 reactions 2 assignees Assigned to @avolkovi View on GitHub
api: firestore needs-attention question testing-sdk
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### [REQUIRED] Describe your environment

* Operating System version: N/A
* Browser version: N/A
* Firebase SDK version: N/A
* Firebase Product: firestore

### [REQUIRED] Describe the problem

In firestore rules, if you `get()` a document that does not exists, the get throw an error instead of returning `null` as described in the documentation: https://firebase.google.com/docs/reference/rules/rules.firestore#.get

Note that it works fine when you use the "rules tester" in the firebase console. But it fails on prod or with the emulator.

#### Steps to reproduce:

```
match /test/{test} {
allow create: if get(/databases/$(database)/documents/doesNotExist/doesNotExist) == null;
}
```

And try to create a document.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.