익명 방문자의 사용자 카드가 `card.json?include_post_count_for`에서 "500 Internal Server Error"로 즉시 사라집니다

안녕하세요. 이 문제가 얼마나 오래 지속되고 있는지 정확히 모르겠고, 방금 최신 버전으로 업데이트한 자체 호스팅 Discourse 인스턴스에서만 재현할 수 있습니다.

익명 방문자가 어떤 사용자의 아바타를 클릭하면 사용자 카드의 윤곽선이 몇 밀리초 동안 표시되었다가 즉시 사라집니다. F12 오류 콘솔에는 다음과 같은 내용이 표시됩니다:

GET   https://example.com/u/UserName/card.json?include_post_count_for=xxxxx

Status  500 Internal Server Error
Version  HTTP/2
Transferred  294 B (46 B size)
Referrer Policy  strict-origin-when-cross-origin
Request Priority  Highest

이 문제는 안전 모드에서도 발생합니다.

hide user profiles from public(공개에서 사용자 프로필 숨김) 설정은 활성화되어 있지 않지만, 며칠 전에 활성화해 본 적이 있습니다. 이것이 관련이 있는지 확실하지는 않습니다.

이것은 사용자의 사용자 카드에 게시글 수를 포함하려는 귀하의 노력과 관련이 있을 수 있습니다. 결국 이 기능을 위해 플러그인을 만들었나요?

아니요, 그걸 제대로 동작시킨 적이 없습니다. 어쨌든 그건 안전 모드에서 비활성화되어 있었을 것입니다.

?include_post_count_for=xxxxx의 숫자는 사용자 ID가 아니라 토픽 ID입니다.

오류가 나는 함수는 사용자 카드에 표시되는 “이 토픽에 X개의 게시글” 버튼용이라고 가정했습니다.

안전 모드는 프론트엔드 코드만 비활성화하고 일부 서버 측 설정은 그대로 유지되므로, 안전 모드에서 발생하더라도 여전히 플러그인 문제일 수 있습니다. 관련 정보가 더 포함된 최근 게시글이 여기에 있습니다: Safe-mode failed with a plugin - #4 by david

저의 테스트 사이트에서는 이 문제를 재현할 수 없습니다. 영향이 있을 수 있는 플러그인, 추가 설정 또는 특이한 사항이 있나요? /logs에 오류에 대한 추가 정보가 있는지 확인해 보셨나요?

음, 감사합니다. 말씀하신 대로인 것 같네요. 이 플러그인 때문이었어요:

@pfaffman 님을 멘션합니다.

Message (184 copies reported)

NoMethodError (undefined method `in_any_groups?' for nil:NilClass)
lib/plugin/instance.rb:301:in `public_send'
lib/plugin/instance.rb:301:in `block (2 levels) in add_to_class'
app/serializers/user_card_serializer.rb:144:in `can_send_private_message_to_user'
(eval):18:in `_fast_attributes'
app/controllers/application_controller.rb:545:in `render_json_dump'
app/controllers/users_controller.rb:147:in `block (2 levels) in show'
app/controllers/users_controller.rb:140:in `show'
app/controllers/users_controller.rb:152:in `show_card'
app/controllers/application_controller.rb:414:in `block in with_resolved_locale'
app/controllers/application_controller.rb:414:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:367:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:228:in `call'

Backtrace

plugins/discourse-allow-pm-to-staff/plugin.rb:52:in `block (2 levels) in activate!'
lib/plugin/instance.rb:301:in `public_send'
lib/plugin/instance.rb:301:in `block (2 levels) in add_to_class'
app/serializers/user_card_serializer.rb:144:in `can_send_private_message_to_user'
(eval):18:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:343:in `as_json'

세 번째 당사 플러그인 관련 문제라 Support 채널로 넘겼어요. :+1:

업그레이드 후에도 이 문제가 지속됩니까?

수년간 수정되지 않은 플러그인의 원래 버전을 사용할 때는 이 문제를 전혀 느끼지 못했습니다. 그런데 업데이트 후 사용자 간 개인 메시지가 작동하지 않게 되자 플러그인을 비활성화했습니다. 그리고 이제 최신 수정 사항과 함께 플러그인을 다시 활성화한 후 이 문제를 발견하게 되었습니다.

그러니까 문제가 여전히 지속되는 건가요?

익명 사용자에게 사용자 카드가 사라지는 문제는 GitHub - pfaffman/discourse-allow-pm-to-staff: Allow private messages to be sent to staff for users who could otherwise not send private messages. · GitHub 플러그인이 활성화된 상태에서 발생하며, 플러그인을 비활성화하면 해결됩니다.

이 버그는 이제 수정되었을 것으로 생각합니다. 아직 업그레이드를 하지 않으셨다면 업그레이드해 주세요.

수정된 것을 확인했습니다. 감사합니다!