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

477
Visualizações
Why do I get an insufficient permissions error while trying to delete an array element from firestore, yet I can delete the entire document

I have a collection in my firestore named "reports"

one of the fields in the reports map is an array of objects. These objects reference a photo in cloud storage. They look like this (url points to cloud storage):

{
   id: uid value
   url: some-url
}

my firebase rules are set up like this for the reports document:

match /databases/{database}/documents {
    match /reports/{report} {
      allow read: if request.auth != null && request.auth.uid == resource.data.userID;
      allow create: if request.auth != null && request.resource.data.userID == request.auth.uid;
      allow delete, update: if request.auth != null &&
      request.auth.uid == resource.data.userID;
    }
}

for some reason, I can delete the entire document if I want to proving that I have delete permission.....but when I attempt to delete an item from the photos array like this:

const reportRef = db.collection('reports')
reportRef.doc(activeReport.id).update({
    photos: firebase.firestore.FieldValue.arrayRemove(photoToDelete)
})

I end up with an error stating:

Unhandled promise rejection: FirebaseError: Missing or insufficient permissions

Why? Haven't I given permission to update this document properly?

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

0

Go in Database -> Rules ->

For development:

Change allow read, write: if false; to true;

Note: It's a quick solution for development purposes only because it will turn off all the security. So, it's not recommended for production.

For production:

If authenticated from firebase: Change allow read, write: if false; to request.auth != null;

about 4 years ago · Juan Pablo Isaza Relatório

0

In this case it was a bad parameter that was passed in. I needed to pass activeReport not activeReport.id.

This is a misleading error message. I would delete this question but stackoverflow doesn't want me to because an answer has been posted here. Silly.

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