Closed eleith closed 5 years ago
Sorry I missed this. That's odd, let me look into it!
Interesting, this error usually comes up only when either rules compilation timed out or the AST tree is too deep. Can you share the proto you used for this, or provide a simple repro?
syntax = "proto3";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
message ABCDEFG1 {
string name = 2;
int32 model_version = 3;
enum Type {
STRING = 0;
INTEGER = 1;
BOOLEAN = 2;
FLOAT = 3;
URI = 4;
DATE = 5;
DATE_TIME = 6;
TIMESTAMP = 7;
DATE_AND_OR_TIME = 8;
}
Type type = 4;
repeated string category = 5;
repeated google.protobuf.Any value = 6;
enum CollectionType {
ABCDZYX1 = 0;
ABCDZYX2 = 1;
}
CollectionType collection_type = 7;
string collection_uid= 8;
string account_uid = 9;
}
message ABCDEFG2 {
int32 model_version = 2;
string account_id = 3;
}
message ABCDEFG3 {
int32 model_version = 2;
string name = 3;
bool something = 4;
string type = 5;
}
message ABCDEFG4 {
string url = 2;
string mimetype = 3;
string model_version = 4;
string account_id = 5;
}
message ABCDEFG5 {
int32 model_version = 2;
enum ABCZYX123 {
ABCEEE = 0;
ABCDDD = 1;
ABCFFF = 2;
}
ABCZYX123 change_type = 3;
repeated google.protobuf.Any from = 4;
repeated google.protobuf.Any to = 5;
string field_id = 6;
string field_key = 7;
}
message ABCDEFG6 {
string name = 1;
string manufacturer = 2;
string appVersion = 3;
string os = 4;
string osVersion = 5;
google.protobuf.Timestamp lastLoggedIn = 6;
int32 model_version = 7;
string account_uid = 8;
}
message ABCDEFG7 {
string ABCDPPP = 2;
string ABCDQQQ = 3;
enum ABCDIIII {
ABCDGGGG = 0;
ABCDKKKLLL = 1;
ABCDOOOOO = 2;
}
ABCDIIII ABCDLLLL = 4;
int32 model_version = 5;
string ABCDRRRR = 6;
repeated string ABCDJJJJ = 7;
}
it was a few weeks ago so a lot has changed on the file i was working on. i took a snapshot back then and just mangled up the field names but i think this should work.
convert this proto to a rules file (it will end up being about 77Kb). we then added this output to our existing rules file that did basic authentication on five collections we are using for firestore.
we were unable to deploy these rules but without an appropriate error message. after reducing the size of our rules a bit, then we finally got the "complex" error messages i referred to in the first post.
we've sinced worked around this by hand tuning our rules and being more precise to how we are using our app, rather than handling every possible scenario / combination of fields being submitted.
not an error with this project, but certainly an unexpected "error" by end users of this project.
if you generate rules for something with like 10 fields, you end up with an enormous conditional. when submitting such an auto generated rule to firestore through the CLI, you end up with this error
Expression is too complex to evaluate safely.
i got around this by just reducing a number of the conditionals that i didn't want to support.
what made this more problematic was that when i had many such rules, the firebase deploy didn't give me a helpful error message. it wasn't until i reduced the rules, hunting for some combination that did pass, that i eventually got a useful error message.
so something on firebase CLI was swallowing these errors, making it even harder to debug.
anyhow, thanks for this fantastic tool! feel free to close as it isn't a but with the tool itself, but may be useful for others that run into this.