Skip to content

fix: resolve fave/unfave cross-campaign collision and NoResultFound error#540

Open
ayushshukla1807 wants to merge 1 commit into
hatnote:masterfrom
ayushshukla1807:fix/fave-cross-campaign-collision
Open

fix: resolve fave/unfave cross-campaign collision and NoResultFound error#540
ayushshukla1807 wants to merge 1 commit into
hatnote:masterfrom
ayushshukla1807:fix/fave-cross-campaign-collision

Conversation

@ayushshukla1807
Copy link
Copy Markdown

Fixes #526, fixes #527.

Root cause: fave() queried Favorite only by entry_id + user, ignoring campaign_id. If the same image appeared in two campaigns, it would find the fave from the other campaign and activate it -- creating a cross-campaign state collision.

Fix: Scope the existence check to campaign_id in fave(). The round_entry lookup already happens anyway (for creating the new fave), so fetching campaign_id from it adds no extra query.

Also fixed: unfave() used .one() which raises NoResultFound if the fave was never created (e.g. due to a prior collision or partial state). Changed to .one_or_none() with an explicit guard -- unfaving something that is not faved is a no-op, not a 500 error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant