Adding tag to two or more groups breaks the tag

All my tag groups are the same, with no restrictions in the groups themselves.

The “Viewer Plugins” category I was testing with does not restrict tags to a particular group:

But three other forum categories do restrict them:

At the database level:

discourse=> select * from category_tag_groups;
 id | category_id | tag_group_id |         created_at         |         updated_at
----+-------------+--------------+----------------------------+----------------------------
  1 |          16 |            2 | 2017-03-20 16:28:47.375592 | 2017-03-20 16:28:47.375592
  2 |          30 |            2 | 2017-08-29 16:49:17.095534 | 2017-08-29 16:49:17.095534
  3 |          11 |            1 | 2017-12-16 10:22:30.399025 | 2017-12-16 10:22:30.399025
(3 rows)

discourse=> select * from tag_groups;
 id |         name         |         created_at         |         updated_at         | parent_tag_id | one_per_topic
----+----------------------+----------------------------+----------------------------+---------------+---------------
  1 | Help Topics          | 2017-01-30 11:55:06.698087 | 2017-01-30 11:55:06.698087 |               | f
  2 | Button/Script Topics | 2017-03-20 16:28:23.544721 | 2017-03-20 16:28:23.544721 |               | f
  3 | Old Plugins          | 2018-08-28 04:31:18.674092 | 2018-08-28 04:31:18.674092 |               | f
  4 | Viewer Plugins       | 2018-08-28 04:55:37.54499  | 2018-08-28 04:55:37.54499  |               | f
(4 rows)
discourse=> select * from category_tags;
 id | category_id | tag_id | created_at | updated_at
----+-------------+--------+------------+------------
(0 rows)
discourse=> select * from tag_group_permissions;
 id | tag_group_id | group_id | permission_type |         created_at         |         updated_at
----+--------------+----------+-----------------+----------------------------+----------------------------
  3 |            3 |        0 |               1 | 2018-08-28 04:31:18.694836 | 2018-08-28 04:31:18.694836
 15 |            2 |        0 |               1 | 2018-08-28 06:19:24.918843 | 2018-08-28 06:19:24.918843
 16 |            1 |        0 |               1 | 2018-08-28 06:19:33.527234 | 2018-08-28 06:19:33.527234
 17 |            4 |        0 |               1 | 2018-08-28 06:19:40.665686 | 2018-08-28 06:19:40.665686
(4 rows)
discourse=> select * from tags;
 id |        name         | topic_count |         created_at         |         updated_at         | pm_topic_count
----+---------------------+-------------+----------------------------+----------------------------+----------------
 17 | cats                |           1 | 2017-02-03 01:22:57.50731  | 2017-02-03 01:22:57.50731  |              0
 20 | lister              |           0 | 2017-03-20 16:28:23.523937 | 2017-03-20 16:28:23.523937 |              0
 21 | meta                |           0 | 2017-03-20 16:28:23.527058 | 2017-03-20 16:28:23.527058 |              0
  4 | wildcards           |           1 | 2017-01-30 11:55:06.572007 | 2017-01-30 11:55:06.572007 |              0
 15 | translation         |          12 | 2017-01-30 15:24:06.044196 | 2017-01-30 15:24:06.044196 |              0
 24 | perl                |           2 | 2017-08-30 17:56:34.466659 | 2017-08-30 17:56:34.466659 |              0
  7 | dupe-finder         |           1 | 2017-01-30 11:55:06.608334 | 2017-01-30 11:55:06.608334 |              0
 25 | python              |           0 | 2017-08-30 17:56:34.50015  | 2017-08-30 17:56:34.50015  |              0
  6 | synchronize         |           6 | 2017-01-30 11:55:06.599565 | 2017-01-30 11:55:06.599565 |              0
 28 | numbering           |           0 | 2017-08-31 19:15:47.071148 | 2017-08-31 19:15:47.071148 |              0
 29 | characters          |           0 | 2017-08-31 19:15:47.117646 | 2017-08-31 19:15:47.117646 |              0
 31 | multi-col           |           1 | 2018-03-26 22:47:26.978476 | 2018-03-26 22:47:26.978476 |              0
 32 | shell-col           |           3 | 2018-03-26 22:47:27.007196 | 2018-03-26 22:47:27.007196 |              0
  3 | regex               |          18 | 2017-01-30 11:55:06.562673 | 2017-01-30 11:55:06.562673 |              0
 12 | archives            |           3 | 2017-01-30 11:55:06.652326 | 2017-01-30 11:55:06.652326 |              0
 33 | 32-bit-only         |           8 | 2018-08-28 04:31:18.578864 | 2018-08-28 04:31:18.578864 |              0
 44 | not-free            |           3 | 2018-08-28 04:55:37.528065 | 2018-08-28 04:55:37.528065 |              0
 35 | broken-links        |           3 | 2018-08-28 04:31:18.65364  | 2018-08-28 04:31:18.65364  |              0
 34 | superseded          |           8 | 2018-08-28 04:31:18.646539 | 2018-08-28 04:31:18.646539 |              0
 37 | meta-obsolete       |           3 | 2018-08-28 04:41:24.087057 | 2018-08-28 04:41:24.087057 |              0
 38 | opus-native         |           0 | 2018-08-28 04:55:37.490169 | 2018-08-28 04:55:37.490169 |              0
 14 | plugin-development  |          21 | 2017-01-30 12:00:51.563514 | 2017-01-30 12:00:51.563514 |              0
  8 | feature-request     |         182 | 2017-01-30 11:55:06.617124 | 2017-01-30 11:55:06.617124 |              0
 26 | metadata            |           3 | 2017-08-30 18:57:21.776829 | 2017-08-30 18:57:21.776829 |              0
 45 | comes-with-windows  |           1 | 2018-08-28 04:56:20.809373 | 2018-08-28 04:56:20.809373 |              0
 36 | no-unicode-support  |           8 | 2018-08-28 04:31:18.660326 | 2018-08-28 04:31:18.660326 |              0
 16 | 3rd-party-dll-crash |          12 | 2017-01-31 01:18:23.847881 | 2017-01-31 01:18:23.847881 |              0
  2 | rename              |          12 | 2017-01-30 11:55:06.553184 | 2017-01-30 11:55:06.553184 |              0
 19 | column              |          13 | 2017-03-20 16:28:23.520827 | 2017-03-20 16:28:23.520827 |              0
 40 | media-tag-reader    |           2 | 2018-08-28 04:55:37.504437 | 2018-08-28 04:55:37.504437 |              0
 11 | viewer              |          25 | 2017-01-30 11:55:06.644568 | 2017-01-30 11:55:06.644568 |              0
 42 | source-available    |           8 | 2018-08-28 04:55:37.516272 | 2018-08-28 04:55:37.516272 |              0
  5 | find                |           1 | 2017-01-30 11:55:06.584397 | 2017-01-30 11:55:06.584397 |              0
 10 | windows-search      |           1 | 2017-01-30 11:55:06.633681 | 2017-01-30 11:55:06.633681 |              0
 41 | comes-with-opus     |           6 | 2018-08-28 04:55:37.510272 | 2018-08-28 04:55:37.510272 |              0
 30 | events              |           8 | 2017-11-20 22:39:51.680956 | 2017-11-20 22:39:51.680956 |              0
 39 | thumbnails          |          14 | 2018-08-28 04:55:37.498571 | 2018-08-28 04:55:37.498571 |              0
 13 | commands            |         110 | 2017-01-30 11:55:06.660153 | 2017-01-30 11:55:06.660153 |              0
 22 | vbscript            |          34 | 2017-03-20 16:28:23.530339 | 2017-03-20 16:28:23.530339 |              0
 18 | button              |          86 | 2017-03-20 16:28:23.498939 | 2017-03-20 16:28:23.498939 |              0
 23 | jscript             |          49 | 2017-03-20 16:28:23.533286 | 2017-03-20 16:28:23.533286 |              0
  1 | scripting           |         385 | 2017-01-30 11:55:06.537469 | 2017-01-30 11:55:06.537469 |              0
  9 | bug-report          |         219 | 2017-01-30 11:55:06.625241 | 2017-01-30 11:55:06.625241 |              0
 27 | user-interface      |           6 | 2017-08-31 00:45:55.33261  | 2017-08-31 00:45:55.33261  |              0
(44 rows)
discourse=> select * from tag_group_memberships;
 id | tag_id | tag_group_id |         created_at         |         updated_at
----+--------+--------------+----------------------------+----------------------------
  1 |      1 |            1 | 2017-01-30 11:55:06.704593 | 2017-01-30 11:55:06.704593
  2 |      2 |            1 | 2017-01-30 11:55:06.70861  | 2017-01-30 11:55:06.70861
  3 |      3 |            1 | 2017-01-30 11:55:06.711579 | 2017-01-30 11:55:06.711579
  4 |      4 |            1 | 2017-01-30 11:55:06.714741 | 2017-01-30 11:55:06.714741
  5 |      5 |            1 | 2017-01-30 11:55:06.717655 | 2017-01-30 11:55:06.717655
  6 |      6 |            1 | 2017-01-30 11:55:06.720509 | 2017-01-30 11:55:06.720509
  7 |      7 |            1 | 2017-01-30 11:55:06.723438 | 2017-01-30 11:55:06.723438
  8 |      8 |            1 | 2017-01-30 11:55:06.72625  | 2017-01-30 11:55:06.72625
  9 |      9 |            1 | 2017-01-30 11:55:06.729034 | 2017-01-30 11:55:06.729034
 10 |     10 |            1 | 2017-01-30 11:55:06.731797 | 2017-01-30 11:55:06.731797
 12 |     12 |            1 | 2017-01-30 11:55:06.741488 | 2017-01-30 11:55:06.741488
 13 |     13 |            1 | 2017-01-30 11:55:06.747079 | 2017-01-30 11:55:06.747079
 14 |     14 |            1 | 2017-01-30 12:00:51.567893 | 2017-01-30 12:00:51.567893
 15 |     15 |            1 | 2017-01-30 15:24:06.058389 | 2017-01-30 15:24:06.058389
 16 |     16 |            1 | 2017-01-31 01:18:23.875875 | 2017-01-31 01:18:23.875875
 17 |      1 |            2 | 2017-03-20 16:28:23.553505 | 2017-03-20 16:28:23.553505
 19 |     13 |            2 | 2017-03-20 16:28:23.558209 | 2017-03-20 16:28:23.558209
 20 |     18 |            2 | 2017-03-20 16:28:23.559494 | 2017-03-20 16:28:23.559494
 21 |     19 |            2 | 2017-03-20 16:28:23.560835 | 2017-03-20 16:28:23.560835
 22 |     20 |            2 | 2017-03-20 16:28:23.562227 | 2017-03-20 16:28:23.562227
 23 |     21 |            2 | 2017-03-20 16:28:23.5635   | 2017-03-20 16:28:23.5635
 24 |     22 |            2 | 2017-03-20 16:28:23.564923 | 2017-03-20 16:28:23.564923
 25 |     23 |            2 | 2017-03-20 16:28:23.566209 | 2017-03-20 16:28:23.566209
 26 |      3 |            2 | 2017-08-30 17:56:34.455664 | 2017-08-30 17:56:34.455664
 27 |     24 |            2 | 2017-08-30 17:56:34.496446 | 2017-08-30 17:56:34.496446
 28 |     25 |            2 | 2017-08-30 17:56:34.50466  | 2017-08-30 17:56:34.50466
 29 |     26 |            2 | 2017-08-30 18:57:21.783478 | 2017-08-30 18:57:21.783478
 30 |     27 |            2 | 2017-08-31 00:45:55.33669  | 2017-08-31 00:45:55.33669
 33 |     30 |            2 | 2017-11-20 22:39:51.696732 | 2017-11-20 22:39:51.696732
 34 |     31 |            2 | 2018-03-26 22:47:26.995116 | 2018-03-26 22:47:26.995116
 35 |     32 |            2 | 2018-03-26 22:47:27.010827 | 2018-03-26 22:47:27.010827
 36 |     33 |            3 | 2018-08-28 04:31:18.686895 | 2018-08-28 04:31:18.686895
 37 |     34 |            3 | 2018-08-28 04:31:18.690101 | 2018-08-28 04:31:18.690101
 38 |     35 |            3 | 2018-08-28 04:31:18.691548 | 2018-08-28 04:31:18.691548
 39 |     36 |            3 | 2018-08-28 04:31:18.69294  | 2018-08-28 04:31:18.69294
 40 |     37 |            3 | 2018-08-28 04:41:24.093834 | 2018-08-28 04:41:24.093834
 43 |     39 |            4 | 2018-08-28 04:55:37.550546 | 2018-08-28 04:55:37.550546
 44 |     40 |            4 | 2018-08-28 04:55:37.551758 | 2018-08-28 04:55:37.551758
 45 |     41 |            4 | 2018-08-28 04:55:37.552892 | 2018-08-28 04:55:37.552892
 46 |     42 |            4 | 2018-08-28 04:55:37.55414  | 2018-08-28 04:55:37.55414
 47 |     43 |            4 | 2018-08-28 04:55:37.555374 | 2018-08-28 04:55:37.555374
 48 |     44 |            4 | 2018-08-28 04:55:37.55652  | 2018-08-28 04:55:37.55652
 49 |     45 |            4 | 2018-08-28 04:56:20.815517 | 2018-08-28 04:56:20.815517
 53 |     11 |            4 | 2018-08-28 05:17:20.805092 | 2018-08-28 05:17:20.805092
 54 |     47 |            2 | 2018-08-28 06:19:24.906794 | 2018-08-28 06:19:24.906794
 55 |     47 |            1 | 2018-08-28 06:19:33.517114 | 2018-08-28 06:19:33.517114
 56 |     47 |            4 | 2018-08-28 06:19:40.658291 | 2018-08-28 06:19:40.658291
(47 rows)
discourse=> select * from category_tag_stats;
 id | category_id | tag_id | topic_count
----+-------------+--------+-------------
  3 |          11 |      8 |         182
  4 |          30 |     22 |          21
  5 |          30 |     13 |           3
  8 |          30 |      3 |          12
  6 |          30 |      1 |          28
 10 |          11 |      6 |           6
 13 |          30 |     24 |           2
 56 |          33 |     36 |           6
 18 |          17 |      1 |           1
 20 |          32 |      9 |           4
 43 |          16 |     26 |           1
 23 |          30 |     26 |           2
 25 |          11 |      4 |           1
 26 |          30 |     27 |           4
 27 |          31 |      9 |           2
 21 |          11 |     16 |          12
 30 |          11 |      7 |           1
 31 |          29 |     17 |           1
 32 |          30 |     18 |           3
  9 |          11 |      2 |          12
  2 |          16 |     19 |          13
 35 |          16 |     31 |           1
 36 |          16 |     32 |           3
 29 |          16 |     30 |           8
 57 |          34 |     44 |           3
 16 |          16 |     13 |          87
 15 |          16 |     22 |          13
 22 |          16 |     18 |          83
 11 |          16 |     23 |          41
 28 |          11 |      9 |         213
 40 |          11 |      5 |           1
 41 |          11 |     10 |           1
 12 |          16 |      1 |          49
 42 |          16 |     27 |           2
 39 |          16 |      3 |           3
 38 |          11 |      3 |           3
  1 |          30 |     23 |           8
 14 |          11 |     11 |           6
 19 |          11 |     13 |          20
  7 |          11 |     12 |           3
 58 |          34 |     36 |           2
 24 |          11 |     15 |          12
 45 |          33 |     33 |           8
 53 |          34 |     40 |           2
 49 |          34 |     11 |          19
 55 |          34 |     42 |           8
 46 |          33 |     35 |           3
 54 |          34 |     41 |           6
 52 |          34 |     39 |          14
 44 |          33 |     34 |           8
 17 |          11 |      1 |         307
 33 |          11 |     14 |          21
 47 |          33 |     37 |           3
 50 |          34 |     45 |           1
(54 rows)
discourse=> select * from tag_search_data;
 tag_id |                           search_data                            |      raw_data       | locale | version
--------+------------------------------------------------------------------+---------------------+--------+---------
      5 | 'find':1A                                                        | find                | en     |       2
     10 | 'search':3A 'window':2A 'windows-search':1A                      | windows-search      | en     |       2
     16 | '3rd':2A '3rd-party-dll-crash':1A 'crash':5A 'dll':4A 'parti':3A | 3rd-party-dll-crash | en     |       2
     17 | 'cat':1A                                                         | cats                | en     |       2
      6 | 'synchron':1A                                                    | synchronize         | en     |       2
     12 | 'archiv':1A                                                      | archives            | en     |       2
     20 | 'lister':1A                                                      | lister              | en     |       2
     21 | 'meta':1A                                                        | meta                | en     |       2
     26 | 'metadata':1A                                                    | metadata            | en     |       2
      2 | 'renam':1A                                                       | rename              | en     |       2
     19 | 'column':1A                                                      | column              | en     |       2
     11 | 'viewer':1A                                                      | viewer              | en     |       2
      4 | 'wildcard':1A                                                    | wildcards           | en     |       2
     24 | 'perl':1A                                                        | perl                | en     |       2
      8 | 'featur':2A 'feature-request':1A 'request':3A                    | feature-request     | en     |       2
      9 | 'bug':2A 'bug-report':1A 'report':3A                             | bug-report          | en     |       2
     22 | 'vbscript':1A                                                    | vbscript            | en     |       2
      7 | 'dupe':2A 'dupe-find':1A 'finder':3A                             | dupe-finder         | en     |       2
     14 | 'develop':3A 'plugin':2A 'plugin-develop':1A                     | plugin-development  | en     |       2
     25 | 'python':1A                                                      | python              | en     |       2
     15 | 'translat':1A                                                    | translation         | en     |       2
     27 | 'interfac':3A 'user':2A 'user-interfac':1A                       | user-interface      | en     |       2
     28 | 'number':1A                                                      | numbering           | en     |       2
      1 | 'script':1A                                                      | scripting           | en     |       2
     13 | 'command':1A                                                     | commands            | en     |       2
     29 | 'charact':1A                                                     | characters          | en     |       2
     18 | 'button':1A                                                      | button              | en     |       2
     23 | 'jscript':1A                                                     | jscript             | en     |       2
      3 | 'regex':1A                                                       | regex               | en     |       2
     30 | 'event':1A                                                       | events              | en     |       2
     31 | 'col':3A 'multi':2A 'multi-col':1A                               | multi-col           | en     |       2
     32 | 'col':3A 'shell':2A 'shell-col':1A                               | shell-col           | en     |       2
     33 | '32':1A 'bit':3A 'bit-on':2A                                     | 32-bit-only         | en     |       2
     34 | 'supersed':1A                                                    | superseded          | en     |       2
     35 | 'broken':2A 'broken-link':1A 'link':3A                           | broken-links        | en     |       2
     36 | 'no-unicode-support':1A 'support':4A 'unicod':3A                 | no-unicode-support  | en     |       2
     37 | 'meta':2A 'meta-obsolet':1A 'obsolet':3A                         | meta-obsolete       | en     |       2
     38 | 'nativ':3A 'opus':2A 'opus-n':1A                                 | opus-native         | en     |       2
     39 | 'thumbnail':1A                                                   | thumbnails          | en     |       2
     40 | 'media':2A 'media-tag-read':1A 'reader':4A 'tag':3A              | media-tag-reader    | en     |       2
     41 | 'come':2A 'comes-with-opus':1A 'opus':4A                         | comes-with-opus     | en     |       2
     42 | 'avail':3A 'sourc':2A 'source-avail':1A                          | source-available    | en     |       2
     44 | 'free':3A 'not-fre':1A                                           | not-free            | en     |       2
     45 | 'come':2A 'comes-with-window':1A 'window':4A                     | comes-with-windows  | en     |       2
(44 rows)
discourse=> select * from tag_users;
 id | tag_id | user_id | notification_level |         created_at         |         updated_at
----+--------+---------+--------------------+----------------------------+----------------------------
  1 |     11 |     199 |                  3 | 2017-02-11 19:58:50.172773 | 2017-02-11 19:58:50.172773
  2 |     14 |   10242 |                  4 | 2017-09-21 02:14:37.388988 | 2017-09-21 02:14:37.388988
  3 |      3 |   11012 |                  4 | 2018-08-08 16:24:27.230327 | 2018-08-08 16:24:27.230327
  4 |      2 |   11012 |                  4 | 2018-08-08 16:24:27.245462 | 2018-08-08 16:24:27.245462
  5 |      8 |   11012 |                  3 | 2018-08-08 16:24:27.256811 | 2018-08-08 16:24:27.256811
  6 |     13 |   11012 |                  3 | 2018-08-08 16:24:27.260248 | 2018-08-08 16:24:27.260248
  7 |     18 |   11012 |                  3 | 2018-08-08 16:24:27.262586 | 2018-08-08 16:24:27.262586
  8 |     14 |   11012 |                  2 | 2018-08-08 16:24:27.271038 | 2018-08-08 16:24:27.271038
  9 |     22 |   11012 |                  0 | 2018-08-08 16:24:27.280543 | 2018-08-08 16:24:27.280543
 10 |      1 |   11012 |                  0 | 2018-08-08 16:24:27.282673 | 2018-08-08 16:24:27.282673
 11 |     23 |   11012 |                  0 | 2018-08-08 16:24:27.284682 | 2018-08-08 16:24:27.284682
 12 |     16 |   11012 |                  0 | 2018-08-08 16:24:27.286522 | 2018-08-08 16:24:27.286522
 13 |      9 |   11012 |                  0 | 2018-08-08 16:24:27.288647 | 2018-08-08 16:24:27.288647
(13 rows)
discourse=> select * from topic_tags;
  id  | topic_id | tag_id |         created_at         |         updated_at
------+----------+--------+----------------------------+----------------------------
    2 |    15783 |      1 | 2017-01-30 11:56:51.313274 | 2017-01-30 11:56:51.313274
    3 |    20781 |      1 | 2017-01-30 11:56:51.413131 | 2017-01-30 11:56:51.413131
    4 |    23832 |      1 | 2017-01-30 11:56:51.457009 | 2017-01-30 11:56:51.457009
    5 |    24265 |      1 | 2017-01-30 11:56:51.495019 | 2017-01-30 11:56:51.495019

                             ... lots more data ...

 1414 |     1199 |     41 | 2018-08-28 07:14:06.512767 | 2018-08-28 07:14:06.512767
 1415 |     1199 |     39 | 2018-08-28 07:14:06.517445 | 2018-08-28 07:14:06.517445
 1416 |       68 |     11 | 2018-08-28 07:14:29.202551 | 2018-08-28 07:14:29.202551
 1417 |       68 |     42 | 2018-08-28 07:14:29.206621 | 2018-08-28 07:14:29.206621
 1418 |       68 |     41 | 2018-08-28 07:14:29.210458 | 2018-08-28 07:14:29.210458
 1419 |       68 |     39 | 2018-08-28 07:14:29.214275 | 2018-08-28 07:14:29.214275
 1420 |    29761 |      1 | 2018-08-28 19:30:31.690668 | 2018-08-28 19:30:31.690668
(1289 rows)