Alberto Di Gioacchino
Alberto Di Gioacchino

Reputation: 705

Firestore rules: maximum of 1000 expressions to evaluate has been reached

I added a new functionality to my application and now I'm getting this error:

maximum of 1000 expressions to evaluate has been reached

raised by firestore rules.

Because of it seems there are much less 1000 controls to be done for that specific write, I would like to ask some suggestions to avoid this behaviour or to introduce some vulnerabilities.

Do you have any advice to avoid this problem?

Upvotes: 6

Views: 1249

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317497

Logical expression are short circuited.

An expression is anything that evaluates to some value. For example, true is one expression. false || false is three expressions.

There is no roadmap to change the limit. The limit is in place in order to prevent excessive resources being used by every operation. Bear in mind also that security rules are free (except for document access), and there is always going to be strict limits on what is provided for free.

Since we can't see your rules, it's not really possible to recommend exact advice. You should consider using functions to cut down on the number of expressions evaluated for some access. If you find yourself typing things like request.resource.data.foo a lot, consider using a function and pass request.resource.data to it to extract values rather than evaluating request.resource.data repeatedly, which is three expressions.

Upvotes: 7

Related Questions