MarcP  
                
                  
                    November 11, 2020,  4:52am
                   
                  1 
               
             
            
              Hello all,
I accidently added tag A as synonym under tag A (accidently, on phone).
Delete synonym gives error 500 
Unlink button gives error 422 
Delete tag gives unknown error 
 
Might be helpful
I can rename tag A to B and the synonym also gets edited. 
Having 0 or 1 post with tag A makes no different for the errors above. 
 
Can someone reproduce this?
             
            
              2 Likes 
            
            
           
          
            
              
                simon  
                
                  
                    November 11, 2020,  5:47pm
                   
                  2 
               
             
            
              
That seems like something that should not be allowed to happen. I’m assuming that you ended up with something like this:
I’m testing this on my local development site. After creating the synonym, clicking the “Remove Synonym” button gives a 422 error. Clicking the trash icon for the synonym doesn’t give me a 500 error, instead it completely deletes the tag.
I think some protection should be added to prevent a tag from being set as its own synonym.
             
            
              1 Like 
            
            
           
          
            
              
                MarcP  
              
                  
                    November 11, 2020,  5:58pm
                   
                  3 
               
             
            
              Thanks for checking this issue.
Hmm ok that is different from my installation. I have no way to delete the tag or synonym at this point.
             
            
              
            
           
          
            
              
                simon  
              
                  
                    November 11, 2020,  6:00pm
                   
                  4 
               
             
            
              
What version of DIscourse is your site on?
             
            
              1 Like 
            
            
           
          
            
              
                MarcP  
              
                  
                    November 11, 2020,  6:30pm
                   
                  5 
               
             
            
              I just upgraded to the newest build:
The behavior is the same as my OP.
             
            
              1 Like 
            
            
           
          
            
            
              We should assign this next week @eviltrout , adding a tag as a synonym of itself is … not good.
             
            
              2 Likes 
            
            
           
          
            
              
                techAPJ  
              
                  
                    November 17, 2020,  1:26am
                   
                  9 
               
             
            
            
              4 Likes 
            
            
           
          
            
              
                techAPJ  
              
                  
                    November 20, 2020,  4:58am
                   
                  12 
               
             
            
              Opening this topic per @MarcP ’s request. He is not able to delete the tag even via console.
cd /var/discourse
./launcher enter app
rails c
tag = Tag.find_by_name("tag_name")
tag.destroy
The above is not working for Marc while it’s working for me. Can you expand your issue here Marc?
             
            
              3 Likes 
            
            
           
          
            
              
                MarcP  
              
                  
                    November 20, 2020,  8:41pm
                   
                  13 
               
             
            
              The command @techAPJ  send me did not work for me, however I ran the (slightly different) commands found in: How can I delete a tag in development database (on local)? 
I got the following results, trying to delete my tag “testing” which has a synonym tag: “testing”.
[1] pry(main)> t = Tag.find_by_name('testing')
=> #<Tag:0x000055a268f6f990
 id: 35,
 name: "testing",
 topic_count: 0,
 created_at: Wed, 11 Nov 2020 04:38:06 UTC +00:00,
 updated_at: Thu, 19 Nov 2020 03:44:35 UTC +00:00,
 pm_topic_count: 0,
 target_tag_id: 35>
[2] pry(main)> t.destroy!
SystemStackError: stack level too deep
from /var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.3/lib/active_record/reflection.rb:120:in `_reflect_on_association'
[3] pry(main)> 
            
              
            
           
          
            
              
                sam  
              
                  
                    November 22, 2020, 11:27pm
                   
                  14 
               
             
            
              try:
DB.exec("delete from tags where name = 'testing'")
 
            
              5 Likes 
            
            
           
          
            
              
                MarcP  
              
                  
                    November 23, 2020,  5:51pm
                   
                  15 
               
             
            
              
This worked! Thanks Sam 
             
            
              2 Likes