Error adding tag synonym when both already exist on a topic

It seems like current code can’t handle creating synonyms in case that the topic already contained both tags before creating a synonym.

Started POST "/tag/solstrip/synonyms" for 3.14.14.5 at 2020-02-29 12:07:28 +0000
Processing by TagsController#create_synonyms as */*
  Parameters: {"synonyms"=>["solstrips"], "tag_id"=>"solstrip"}
Completed 500 Internal Server Error in 46ms (ActiveRecord: 0.0ms | Allocations: 6385)
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_topic_tags_on_topic_id_and_tag_id"
DETAIL:  Key (topic_id, tag_id)=(14651, 310) already exists.
)
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.1.6/lib/patches/db/pg.rb:69:in `exec_params'
Failed to handle exception in exception app middleware : PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_topic_tags_on_topic_id_and_tag_id"
DETAIL:  Key (topic_id, tag_id)=(14651, 310) already exists.

Can anybody please confirm it and probably move to #bugs ? Thx!

4 Likes

Yes, this issue is happening on our discourse installation too.

1 Like

Confirmed this is still happening on latest code.

4 Likes

@vinothkannans can you sort this out?

2 Likes

This is now fixed in the below commit

5 Likes