Reputation: 189
I am using Firebase RTDB, using the pyrebase4 python3 wrapper: pyrebase
I have two python3 modules that have almost the same code for this small sample project, but when I run the code it fails.
attendance.py
attendance_within_date = self.firebase_db.child(f"{w_game}/{attendance_db_child}").order_by_key().start_at(str(t_start_time)).end_at(str(t_end_time)).get()
quest.py
quest_within_date = self.firebase_db.child("genshin/quests").order_by_key().start_at(str(e_start_time)).end_at(str(e_end_time)).get()
The quest.py line of code works just fine, but attendance.py over here keeps getting this error, traceback from logs:
2021-06-23 13:41:26,638 ERROR A1RPGAttendance, aggregate_attendance_firebase - Incorrect inputs?: [Errno 400 Client Error: Bad Request for url: https://SECRET.firebaseio.com/%20genshin/attendance_test.json?orderBy=%22%24key%22&startAt=%221621839600.0%22&endAt=%221621839600.0%22] {
"error" : "Provided string key index is invalid"
}
I am unsure what the problem is. The Firebase rules have the same rules for each document/collection.
Upvotes: 0
Views: 106
Reputation: 599131
firebaser here
You have a dot (.
) in the values that you're trying to filter on, but dots are not allowed to exist in keys. You'll want to trim those from the values you pass to Firebase.
I admit to also having to double check with the database engineers, so they filed an internal issue to improve that error message.
Upvotes: 1