Comment 0 for bug 802868

Revision history for this message
Michael Nelson (michael.nelson) wrote :

We're seeing numerous oopses each day on reviews.ubuntu.com for posts to (for example) /reviews/api/1.0/reviews/11039/recommendations/

with tracebacks like: https://pastebin.canonical.com/49101/

We lose the original trackback because a second exception is recorded while piston-miniclient tries to log the error, but there's enough info to be certain that the issue is in reviewsapp.api.handlers.SubmitUsefulnessHandler.create:
{{{
        usefulness, created = Usefulness.objects.get_or_create(
            review=review, user=request.user)
}}}
The MultipleObjectsReturned seems to imply that it is already possible for a user to create 2 recommendations for a single review... and we're erroring when they try to create a third :). Checking the model, there is currently no db constraint for this on the Usefulness model... we should add one with a migration to delete duplicates (or is there a reason why a single user should have multiple recommendations for a review?)