firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firestore emulator's rules error message show wrong error and line

Open readyiman opened this issue 4 years ago • 0 comments

[REQUIRED] Environment info

firebase-tools: 9.23.0

Platform: Windows, Flutter, VSCode

[REQUIRED] Test case

(69)	match /users/{userId} {
(70)		allow create: 
(71)			if request.auth != null 
(72)			&& request.auth.uid == userId
(73)			&& request.resource.data.handleName == null;

[REQUIRED] Steps to reproduce

  1. Just usual way to create Firestore document.
await ref.set({
   handleName = 'name'
});
  1. Give that handleName a String.

[REQUIRED] Expected behavior

false for 'create' @ L73, cause=notnull}.

[REQUIRED] Actual behavior

W/Firestore(13701): (24.0.0) [z0]: (829940f) Stream closed with status: f1{code=PERMISSION_DENIED, description=
W/Firestore(13701): false for 'create' @ L71, cause=null}.
W/Firestore(13701): (24.0.0) [Firestore]: Write failed at users/30Sq17RVXxpp04Eqb3cnH09bYXWs: f1{code=PERMISSION_DENIED, description=
W/Firestore(13701): false for 'create' @ L71, cause=null}

I spent some days to figure it out, because I believe in that error message and something may wrong with Auth (which is not).

readyiman avatar Dec 05 '21 01:12 readyiman