title: Firestore rules not allowing read given valid UID
body: <p>I have written the following firestore rule to limit reads on the users collection by only allowing the request if the caller's UID matches the document ID. There is parity between the users collections' document ID and the UID in Firebase Authentication.</p>
  <pre><code>    function isAuthenticated() {
        return request.auth.uid != null;
      }
  
      // Users collection
      match /users/{userId} {
        allow read: if isAuthenticated() 
          &amp;&amp; request.auth.uid == userId;
      }
  </code></pre>
  <p>I have a document in the collection with ID <code>Eli90wRvWkfKcOfn1C4DBDqxQTz1</code>. When hitting firestore with <strong>the same authentication user</strong>, I get the following error:</p>
  <p><a href="https://i.stack.imgur.com/dqDMU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dqDMU.png" alt="Failed read with uid check" /></a></p>
  <p>If I remove the check for the <code>request.auth.uid == userId</code>, it results in this rule and a successful read:</p>
  <pre><code>    // Users collection
      match /users/{userId} {
        allow read: if isAuthenticated();
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/J7CZm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J7CZm.png" alt="enter image description here" /></a></p>
  <p>The query that is being called is:</p>
  <pre><code>export const getUser = (uid: string) =&gt; {
    return db.collection('users').where('id', '==', uid).limit(1).get();
  };
  </code></pre>
  <p>I've seen many people use the UID check in their rules but why isn't it working in my case?</p>