# Discourse Assign - bug taking site down

**URL:** https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049
**Category:** Bug
**Created:** [9 september 2019 om 15:05 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049 "2019-09-09T15:05:20Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![jerry0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerry0/32/94523_2.png) [@jerry0](https://meta.discourse.org/u/jerry0)
#### Post date: [9 september 2019 om 15:05 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/1 "2019-09-09T15:05:20Z")

</div>

I recently changed the site setting for the group(s) that are able to use Discourse Assign. Something went awfully wrong when I hit the update button, it took the whole site down.

I have since disabled Discourse Assign, which has got the site back up, but I am unable to get Discourse Assign working again. When I re-enable it, the site is taken down, and cannot change the site settings for the Discourse Assign plugin.

I am looking at the error logs, there are two:

```
ActiveRecord::StatementInvalid (PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "patently-staff"
LINE 1: ...RE "group_users"."user_id" = 1 AND (groups.id in ('patently-...
                                                             ^
: SELECT 1 AS one FROM "groups" INNER JOIN "group_users" ON "groups"."id" = "group_users"."group_id" WHERE "group_users"."user_id" = 1 AND (groups.id in ('patently-staff')) LIMIT 1)
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rack-mini-profiler-1.0.2/lib/patches/db/pg.rb:69:in `async_exec_params'

```

And:

```
Failed to handle exception in exception app middleware : PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "patently-staff"
LINE 1: ...RE "group_users"."user_id" = 1 AND (groups.id in ('patently-...
                                                             ^
: SELECT 1 AS one FROM "groups" INNER JOIN "group_users" ON "groups"."id" = "group_users"."group_id" WHERE "group_users"."user_id" = 1 AND (groups.id in ('patently-staff')) LIMIT 1

```

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [9 september 2019 om 15:58 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/2 "2019-09-09T15:58:39Z")

</div>

Is the discourse-assign plugin up to date in your instance? Or maybe you forked the plugin a while ago? There was [a change](https://github.com/discourse/discourse-assign/commit/64324ce9db73959bf2522bcdce0709f201eebf23) in the discourse-assign plugin in July that seems relevant to the errors you’re seeing.

---

<div class="post-metadata">

### Author: ![jerry0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerry0/32/94523_2.png) [@jerry0](https://meta.discourse.org/u/jerry0)
#### Post date: [9 september 2019 om 16:05 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/3 "2019-09-09T16:05:47Z")

</div>

Hi Penar, I’m pretty sure it was up to date, I regularly update everything include plugins.

I think I’m going to have to restore, last backup was before I changed that site setting.

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [9 september 2019 om 16:54 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/4 "2019-09-09T16:54:02Z")

</div>

Hi @jerry0,

According to the logs, it looks like the plugin is up to date. Which Discourse version are you running?

---

<div class="post-metadata">

### Author: ![jerry0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerry0/32/94523_2.png) [@jerry0](https://meta.discourse.org/u/jerry0)
#### Post date: [9 september 2019 om 17:25 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/5 "2019-09-09T17:25:37Z")

</div>

latest, currently 2.4.0.beta4

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [9 september 2019 om 18:04 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/6 "2019-09-09T18:04:35Z")

</div>

Hmm, I see. Did you change the setting before or after updating to `beta4`?

Looks like somehow our automatic migration failed to update you setting, I’m going to investigate why this happened. Did you try restarting the server before enabling the plugin just in case the old value could have been cached? Let me know if this doesn’t work and I’ll provide you a ruby script to manually fix the issue.

---

<div class="post-metadata">

### Author: ![jerry0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerry0/32/94523_2.png) [@jerry0](https://meta.discourse.org/u/jerry0)
#### Post date: [9 september 2019 om 18:15 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/7 "2019-09-09T18:15:13Z")

</div>

Thanks @Roman

> [@Roman](#):
>
> Did you change the setting before or after updating to `beta4` ?

It happened before I updated. Something weird happened as I added the new setting, I think I pressed the green tick before “adding” the new groupname.

> [@Roman](#):
>
> Did you try restarting the server before enabling the plugin

I am not sure how to do that (btw I may have mispoken when saying “disabled/enabled” in my OP - what I meant was that I commented out the `git clone` url in the app.yml file to add the plugin). When I add the plugin in the yml file it crashes the site straight away (and it was previously enabled) so I can’t go in and then set it to disabled… unless I have misunderstood you?

> [@Roman](#):
>
> I’ll provide you a ruby script to manually fix the issue.

May well be needed, would be gratefully received.

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [9 september 2019 om 18:21 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/8 "2019-09-09T18:21:58Z")

</div>

If you don’t mind, I’d like to validate one more thing before manually modifying the setting.

Can you execute this code inside a rails console and let me know the output?

```ruby
DB.query_single(<<~SQL
  SELECT site_settings.value FROM site_settings WHERE site_settings.name = 'assign_allowed_on_groups'
SQL
).first.to_s.split('|')

```

This should tell us if we failed to migrate the setting’s value.

To access a console:

- `cd` into your Discourse folder
- Enter the container running `./launcher enter app`
- Open a Rails console running `rails c`

---

<div class="post-metadata">

### Author: ![jerry0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerry0/32/94523_2.png) [@jerry0](https://meta.discourse.org/u/jerry0)
#### Post date: [9 september 2019 om 18:28 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/9 "2019-09-09T18:28:32Z")

</div>

response is

=\> [“patently-staff”]

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [9 september 2019 om 18:37 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/10 "2019-09-09T18:37:46Z")

</div>

Thanks, Jerry.

There’s definitely something going on here. I’ll have a look and see why it’s happening.

Here’s the script:

```ruby

group_id = Group.where(name: 'patently-staff').pluck(:id).join('|')

DB.exec("UPDATE site_settings SET value='#{group_id}' WHERE site_settings.name = 'assign_allowed_on_groups'")

```

After running it, you should be able to re-enable the plugin.

---

<div class="post-metadata">

### Author: ![jerry0](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jerry0/32/94523_2.png) [@jerry0](https://meta.discourse.org/u/jerry0)
#### Post date: [9 september 2019 om 19:10 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/12 "2019-09-09T19:10:19Z")

</div>

Perfect, that worked 😁 Thank you @Roman. Let me know if there is anything I can provide to assist further.

---

<div class="post-metadata">

### Author: ![diwr](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@diwr](https://meta.discourse.org/u/diwr)
#### Post date: [25 september 2019 om 07:13 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/13 "2019-09-25T07:13:09Z")

</div>

Hello Roman,  
we’ve got a simmilar problem with the discourse-assign plugin on our site after upgrading to 2.4.0beta4.

The Problem only appears on users logging in via ldap. (we use “[GitHub - jonmbake/discourse-ldap-auth: Discourse plugin to enable LDAP/Active Directory authentication. · GitHub](https://github.com/jonmbake/discourse-ldap-auth)” for the ldap connection)

the response to the DB.query is:  
=\> [“staff”]  
but " Group.where(name: ‘staff’).pluck(:id).join(‘|’)" returns “”.

Btw: On Version “2.4.0.beta1 +203” the responses are similar, but login by ldap is possible. (ldap version 0.4.0, assign version 0.1)

Any help welcome,  
Thanks,  
Frank

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [25 september 2019 om 12:07 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/14 "2019-09-25T12:07:43Z")

</div>

Hello @diwr,

According to that query, you don’t have a group called `staff`. Maybe you renamed it to something else?

You can check that by doing: `Group.where(id: 3).pluck(:name)`

I think that the migration won’t work if the `staff` group was renamed. I’ll have a look at this today.

---

<div class="post-metadata">

### Author: ![diwr](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@diwr](https://meta.discourse.org/u/diwr)
#### Post date: [25 september 2019 om 12:14 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/15 "2019-09-25T12:14:13Z")

</div>

Thank you @Roman

it seems it was renamed to “team”  
What to do now?

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [26 september 2019 om 12:27 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/16 "2019-09-26T12:27:58Z")

</div>

You can run the script using “team” as the group name.

---

<div class="post-metadata">

### Author: ![diwr](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@diwr](https://meta.discourse.org/u/diwr)
#### Post date: [26 september 2019 om 13:20 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/17 "2019-09-26T13:20:31Z")

</div>

@Roman  
Thx allot.  
I had to “./launcher rebuild app” after setting the value, but then it worked.

---

<div class="post-metadata">

### Author: ![Roman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/roman/32/157504_2.png) [@Roman](https://meta.discourse.org/u/Roman)
#### Post date: [16 maart 2020 om 17:33 UTC](https://meta.discourse.org/t/discourse-assign-bug-taking-site-down/128049/18 "2020-03-16T17:33:34Z")

</div>


