首页 > 解决方案 > Firestore 规则模拟器 - 子集合的请求为空

问题描述

以下规则在嵌套 (**) 匹配中对“请求”产生错误:

运行模拟时出错 — 错误:simulator.rules 行 [10]、列 [30]。空值错误。

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {

    // Allow users to only edit their records
    match /users/{userId}{
      allow read, update, delete: if request.auth.uid == userId;
      allow create: if request.auth.uid != null;   
      match /{documents=**} {
        allow read, write: if request.auth.uid == userId;
      }
    }    

  }
}

失败的模拟器测试是:

GET: /users/MyUserId/items/MyItemId

这是使用“密码”身份验证,但即使将其作为“未经身份验证”运行也会产生相同的错误,就好像模拟器没有正确编译规则一样。

标签: google-cloud-firestorefirebase-securityfirebase-tools

解决方案


进一步的故障排除表明它可以在数据库中实时工作,而不是在模拟器中。所以一定是模拟器的bug。


推荐阅读