DeleteComments ticket failing

My unit tests are all passing. mflix is not throwing any exceptions while it’s executing, but it is giving me the following error:

Delete Comments: Deletion was performed but unsuccessful.

When I have it outputting the comment that’s being inserted versus the deletes it’s trying to do, the comment IDs do not match. Is anyone else running into the same problem?

yes the same for me. Also that happens with “update comments” - tests pass, but no code from web site’s mflix status

Hi @tjcasser,

Try putting commentId match in query filter. If that also does not work, please share the query.

Kanika

Hi @Marina_37816,

Please share the error you are seeing from console when running the status page.

Kanika

It’s still not working. I’ve actually tried it multiple ways and while the unit tests pass, the production continues to fail.
My current query that validates against the unit tests:

    Bson queryFilter = new Document("_id", new ObjectId(commentId)).append("email", email);
    DeleteResult dr = commentCollection.deleteOne(queryFilter);

What I am noticing (via some convenient System.out.println’s to see how it’s running) is that the mflix site seems to be trying to set the comment with a pre-set ID… and then goes looking for another one anyway.

Inserted comment from mflix:
Comment{id=5ce5d9cd4a50657dd15a2355, oid=5ce5d9cd4a50657dd15a2355, text=feefee, date=Wed May 22 19:22:53 EDT 2019, email=cxlrfh3pd@4goug.8mz, name=ke5o7f60q, movieId=573a13eff29313caabdd82f3, movieObjectId=573a13eff29313caabdd82f3}

Deletes are looking for:
Document{{_id=5a9427658b0beebeb697bc39, email=g9cwpr0bf@vyg4w.y2r}}
Document{{_id=5a9427658b0beebeb697bc39, email=cxlrfh3pd@4goug.8mz}}

5a9427658b0beebeb697bc39 is a different comment within the system.

What do you return as the value of the method?

return dr.getDeletedCount() == 1;

That should work.

Just a wild guess but try to run the portal in incognito mode. Some people got issues with the cache.

I tried that, actually. :frowning: No dice. I’m just soldiering on for the moment, but it annoys me.

If not in the delete that the problem must lie in the insert. Are all the types the same? Some other people where adding _id not being an objectid and deleting with _id being an objectid.

The inserts look like they’re going correctly too. It’s just annoying.

no errors on console unfortunately. Just line turns red when in /status for udate/add comment and for delete comment; while tests for those two tickets run successfully. Please, can you do anything so that I would be able to be graded. I think that I did tickets correctly, when:
1.
mvn test -Dtest=DeleteCommentTest
works

mvn test -Dtest=UpdateCreateCommentTest
works.

If you do something incorrectly with JWT token, while i should lose grades?

Are the comments sorted according to the requirements in getMovie*?

I have exactly the same problem as guys here. Btw. something similar is happening for Create/Update comments Ticket Validation.

Here is my deleteComment implementation:

  public boolean deleteComment(String commentId, String email) {
    // TODO> Ticket Delete Comments - Implement the method that enables the deletion of a user
    // comment
    // TIP: make sure to match only users that own the given commentId
    final Bson filter = and(Arrays.asList(eq("_id", new ObjectId(commentId)), eq("email", email)));
    return commentCollection.deleteOne(filter).getDeletedCount() > 0;
    // TODO> Ticket Handling Errors - Implement a try catch block to
    // handle a potential write exception when given a wrong commentId.
  }

Of course all related unit tests are GREEN.

To answer the question directly - yes, the types are the same.

For the record, the ‘suggested solution’ for create/update comments doesn’t pass when I substitute it for my code. I suspect there’s a deeper problem here with the mflix application’s test suite.

I’ve somewhat accepted that I’m just not going to get the delete working and have moved on.

1 Like

Had the same problem and found the answer was due to missing something that wasn’t caught in a previous step.

Hint:- in the “Get Comments” ticket, the requirements included sorting the comments from newest to oldest. So if you haven’t got a $sort as part of your $lookup pipeline, try going back and adding that and then re-try the delete ticket.

1 Like