firebase / firebase/firebase-tools

resource.data is missing data when evaluating firestore rules in emulator

Open
#4,420 16 comments 7 reactions 1 assignee Claimed by @christhompsongoogle View on GitHub
emulators: firestore type: bug
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

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.