Ticket : $lookup stage return always zero

he there ;

i tried to solve the ticket assignment to implement the $lookup stage with the same approach as shown in the lecture just by changing the field name to ‘comments’ but it is returning zero and can’t pass the test. i tested in my notebook , len(movie.get(‘comments’, )) gives me zero . i couldn’t understand why it is returning zero . i did the same inspection in the compass , this field ‘comments’ is added in some of the documents. but not passing the third test case . any idea please ? here is the screen shot

Hi @Asfetaw_Abay_Abera,

Sending you a message to debug the $lookup query.


here it is

pipeline = [

            "$match": {
                "_id": ObjectId(id)
          { "$lookup":{
                  "from": 'comments',
                  "let": { 'id': '$_id' },
                  "pipeline": [
                    { '$match':
                      { '$expr': { '$eq': [ '$movie_id', '$$id' ] } }
                  "as": 'comments'

This looks correct to me. I am able to pass it.
How many documents are there is sample_mflix.movies collection? and also in comments collection




It looks right. Did you make any more changes?


hi Kanikasingla;

still test cases failed. i didn’t make any change . i am following the course assignment but i am stuck now. i can share you the print screen.

i don’t know what to do.

Hi @Asfetaw_Abay_Abera,

Can you zip the whole project and share it with me on GitHub? If you have it on GitHub that would also work.

If you don’t have GitHub, let me know will share the email address with you.


Thanks @Asfetaw_Abay_Abera, I will take a look and get back to you.


hi kanika;

do you get a time to look on it ? i got stuck here

Looking at it today :slight_smile:

Hi @Asfetaw_Abay_Abera,

I am able to get the validation code for Get Comments ticket. Can you please share the terminal message when you try to get validation code for Get Comments?


hi @kanikasingla;

thank you for your response . that works but my issue is with create_update_comments.

here is another screenshot when i remove ObjectId() from movie_id.

Got it. First screenshot indicates blank id I guess. Let me look at the code and I will get back to you.


Hi @Asfetaw_Abay_Abera,

Found the issue. Sending you a message to share the same. :slight_smile:


hi @kanikasingla,

thank you for your response .i checked and updated ( ObjectId(movie_id)) but still i am receiving the same error message . here is error message that i received . i will send an email to share my code. the messages points on using ObjectId , the input is not valid ObjectId. it is really confusing

sorry it was sent through email


i am not clear why the following error is displayed . can we fix that , that might solve the ticketing issue

bson.errors.InvalidId: ‘’ is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string