List index out of range

Hi

i am trying out this piece of code and don’t understand why i will hit this error " index out of range".

retrieve_rec = mydb.get_collection(each_student[1]).aggregate([{’$project’:{‘NumberOfItemsInArray’:{’$size’:’$record’}}}])

results = [rec for rec in retrieve_rec]

i noted that the error “index out of range” is raised likely due to the “rec for rec in retrieve_rec” which i suspects that sometime goes wrong in the aggregate. but i unable to debug further as running my code in a docker. it works well with my computer using simulated data.

Thank you