Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

366
Visualizações
Firestore rules: Property is undefined on object. for 'list' @ L6

I am having an issue where I am trying to query a subquery by a field, and I have tried the emulator as well as firebase support (still on going, but not solutions yet).

When running the following query:

const queryByNumber = query(
  collectionGroup(this.firestore, 'residents'), 
  where('cellNumber', '==', number)
);
return from(getDocs(queryByNumber)); 

This query has the error of:

Property cellNumber is undefined on object. for 'list' @ L6

This is what the rules look like at the moment

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{path=**}/residents/{residentDoc} {
        allow write: if resource.data.cellNumber == request.auth.token.phone_number;
        allow read: if request.auth.token.phone_number == resource.data.cellNumber;
        //allow read; //temp permission till support fix
      }
      match /Units/{unitNumber} {
        allow read: if request.auth != null;
        function residentDoc(residentId) {
            return get(/databases/$(database)/documents/Units/$(unitNumber)/residents/$(residentId))
        }
        
        match /pets/{petId} {
          allow write: if residentDoc(request.resource.data.residentId).data.cellNumber == request.auth.token.phone_number;
          allow read: if request.auth != null;
        }
      }
    }
}

And this is the firestore data structure at the moment:

firestore data structure

I have tried to change my query to have the array-contains in the where clause, but that doesn't change much.

Note: the allow read without the if check allows the data to be retrieved, so the query does work, just the rules to secure it are not`

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The problem is in this condition in your rules:

request.auth.token.phone_number in resource.data.cellNumber

The in operation in Firestore security rules is only defined for maps and lists/arrays, but your cellNumber field is a simple string value, which does not define an in operation as you can see here.

If you want to check whether the phone number in the token is the same as the value of the field, use == instead of in. If you want to test whether it is in the field, consider using the matches method on the string.

Also see:

  • Firebase firestore security rules allow if document ID contains string
  • Using contains() with firebase rules
about 4 years ago · Juan Pablo Isaza Relatório

0

The issue was another query trying to get all resident data after the initial one was fired, which caused it to fail the rule because the second one wasn't querying by cellNumber anymore. I have changed the rules to validate by UID since that will always be provided

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda