Discourse Assign - bug taking site down

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

Is the discourse-assign plugin up to date in your instance? Or maybe you forked the plugin a while ago? There was a change in the discourse-assign plugin in July that seems relevant to the errors youā€™re seeing.

2 Likes

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.

Hi @jerry0,

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

2 Likes

latest, currently 2.4.0.beta4

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.

1 Like

Thanks @Roman_Rizzi

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.

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?

May well be needed, would be gratefully received.

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?

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
3 Likes

response is

=> [ā€œpatently-staffā€]

1 Like

Thanks, Jerry.

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

Hereā€™s the script:


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.

7 Likes

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

1 Like

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 ā€œ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

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.

2 Likes

Thank you @Roman_Rizzi

it seems it was renamed to ā€œteamā€
What to do now?

You can run the script using ā€œteamā€ as the group name.

4 Likes

@Roman_Rizzi
Thx allot.
I had to ā€œ./launcher rebuild appā€ after setting the value, but then it worked.

6 Likes