firebase / firebase/firebase-tools
resource.data is missing data when evaluating firestore rules in emulator
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools:** 10.6.0
**Platform:** macOS
### [REQUIRED] Test case
The following function in security rule function will return `true` even when the document in question definitely contains the `userId` field
```
function doesntExistOrMissingUserId(){
return resource == null || !resource.data.keys().hasAll(['userId']);
}
```
### [REQUIRED] Steps to reproduce
Add the above function to a `read` rule. Issue a query from a client for a doc that contains a `userId` field. The rule will pass when it should be rejected.
### [REQUIRED] Expected behavior
The rule should be rejected
### [REQUIRED] Actual behavior
The rule evaluates to true
Contributor guide
Assessment
This issue has not been assessed yet.