This is a very interesting bug where it happened when we try to query to check if a product exists or not existing_product = session.query(Product).filter_by(url=url, quantity=quantity).first()
Essentially we thought that it was trying to complain that this product (unique by URL & quantity) has duplicates
We checked that indeed only a single product exists in the database, which makes sense, but why the error then?
Finally, we found out that the issue was with last_price returning more than a single result in column_property
Which makes sense because last_price should only return a single query
Reference: Sentry Issue
Debug Log
existing_product = session.query(Product).filter_by(url=url, quantity=quantity).first()
last_price
returning more than a single result incolumn_property
last_price
should only return a single query