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개의 좋아요

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개의 좋아요

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개의 좋아요

Thanks @Roman

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개의 좋아요

response is

=> [“patently-staff”]

1개의 좋아요

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개의 좋아요

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

1개의 좋아요

Roman님, 안녕하세요.

저희 사이트에서도 2.4.0beta4로 업그레이드한 후 discourse-assign 플러그인에서 유사한 문제를 겪고 있습니다.

이 문제는 LDAP를 통해 로그인하는 사용자에게만 발생합니다. (LDAP 연결에는 "GitHub - jonmbake/discourse-ldap-auth: Discourse plugin to enable LDAP/Active Directory authentication. · GitHub"를 사용하고 있습니다.)

DB.query에 대한 응답은 다음과 같습니다:
=> [“staff”]
하지만 "Group.where(name: ‘staff’).pluck(:id).join(‘|’)"은 “”(빈 문자열)을 반환합니다.

참고: “2.4.0.beta1 +203” 버전에서는 응답이 유사하지만, LDAP 로그인은 가능합니다. (ldap 버전 0.4.0, assign 버전 0.1)

도움이 필요하니 조언을 구합니다.
감사합니다.
Frank

@diwr 님, 안녕하세요.

해당 쿼리에 따르면 staff라는 이름의 그룹이 없습니다. 다른 이름으로 변경된 건가요?

Group.where(id: 3).pluck(:name)을 실행해 확인해 볼 수 있습니다.

staff 그룹이 이름이 변경되었다면 마이그레이션이 작동하지 않을 것 같습니다. 오늘 이 문제를 확인해 보겠습니다.

2개의 좋아요

@Roman 감사합니다

"team"으로 이름이 변경된 것 같습니다.

이제 어떻게 해야 하나요?

그룹 이름으로 "team"을 사용하여 스크립트를 실행할 수 있습니다.

4개의 좋아요

@Roman
고맙습니다.
값을 설정한 후 "./launcher rebuild app"을 실행해야 했는데, 그랬더니 작동했습니다.

6개의 좋아요