ما الذي يمكن أن يسبب أخطاء 500 عند حفظ تفضيلات المستخدم؟

لقد واجهت خطأً غريبًا آخر خلال الأيام القليلة الماضية في نسخة Discourse الخاصة بي. لا يمكنني حفظ أي تفضيلات للمستخدم لمستخدمي الإداري الخاص بي، أحصل فقط على أخطاء 500. يبدو أن الأمر نفسه ينطبق على أي طلب PUT إلى u/[MY_USERNAME].json.

لقد حاولت أيضًا تكرار نفس الطلب في Postman باستخدام مفتاح API صالح، لكن ذلك فشل أيضًا:

لا أرى أي أخطاء تظهر في /logs أيضًا.

لا يبدو أن حسابات المستخدمين الأخرى متأثرة، على الأقل تلك التي جربتها.

تمت ترقية Discourse إلى أحدث إصدار بالأمس، ولكن المشكلة كانت موجودة قبل الترقية أيضًا.

أي أفكار حول كيفية مواصلة تصحيح هذا؟

إذا قمت بزيارة /logs في مثيل Discourse الخاص بك أثناء تسجيل الدخول كمسؤول، فيجب أن يعرض لك المزيد من التفاصيل حول الأخطاء مثل هذا. إذا كان بإمكانك مشاركة محتويات علامتي “info” و “backtrace” للخطأ ذي الصلة، فسيساعدنا ذلك في تتبع المشكلة.

تعديل: أوه، أرى أنك نظرت بالفعل هناك :thinking:. هل يمكنك التحقق مرة أخرى من تمكين جميع أنواع الأخطاء في أسفل اليسار من /logs؟

So I guess it might actually have been this error:

I figured that one was just showing up due to this issue:

However, it turns out it’s all related.

Here are the full logs:

Info:

RegexpError (invalid pattern in look-behind: /((?<!estonia.*\s)\be-residence\b(?!.*estonia))/i)
app/services/word_watcher.rb:264:in `initialize'
app/services/word_watcher.rb:264:in `new'
app/services/word_watcher.rb:264:in `block in replace'
app/services/word_watcher.rb:262:in `each'
app/services/word_watcher.rb:262:in `reduce'
app/services/word_watcher.rb:262:in `replace'
app/services/word_watcher.rb:149:in `replace_link'
app/services/word_watcher.rb:155:in `apply_to_text'
app/models/user_profile.rb:194:in `apply_watched_words'
app/services/user_updater.rb:242:in `block in update'
app/services/user_updater.rb:197:in `update'
app/controllers/users_controller.rb:250:in `block in update'
app/controllers/application_controller.rb:748:in `json_result'
app/controllers/users_controller.rb:244:in `update'
app/controllers/application_controller.rb:420:in `block in with_resolved_locale'
app/controllers/application_controller.rb:420: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:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
config/initializers/008-rack-cors.rb:24: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:233:in `call'

Backtrace:

app/services/word_watcher.rb:264:in `initialize'
app/services/word_watcher.rb:264:in `new'
app/services/word_watcher.rb:264:in `block in replace'
app/services/word_watcher.rb:262:in `each'
app/services/word_watcher.rb:262:in `reduce'
app/services/word_watcher.rb:262:in `replace'
app/services/word_watcher.rb:149:in `replace_link'
app/services/word_watcher.rb:155:in `apply_to_text'
app/models/user_profile.rb:194:in `apply_watched_words'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:400:in `block in make_lambda'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:180:in `block (2 levels) in halting_and_conditional'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:687:in `block (2 levels) in default_terminator'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:686:in `catch'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:686:in `block in default_terminator'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:181:in `block in halting_and_conditional'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:595:in `block in invoke_before'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:595:in `each'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:595:in `invoke_before'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:116:in `block in run_callbacks'
activerecord (7.0.5.1) lib/active_record/autosave_association.rb:370:in `around_save_collection_association'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:138:in `run_callbacks'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:929:in `_run_save_callbacks'
activerecord (7.0.5.1) lib/active_record/callbacks.rb:455:in `create_or_update'
activerecord (7.0.5.1) lib/active_record/timestamp.rb:126:in `create_or_update'
activerecord (7.0.5.1) lib/active_record/persistence.rb:615:in `save'
activerecord (7.0.5.1) lib/active_record/validations.rb:47:in `save'
activerecord (7.0.5.1) lib/active_record/transactions.rb:298:in `block in save'
activerecord (7.0.5.1) lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
activerecord (7.0.5.1) lib/active_record/connection_adapters/abstract/database_statements.rb:314:in `transaction'
activerecord (7.0.5.1) lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
activerecord (7.0.5.1) lib/active_record/transactions.rb:298:in `save'
activerecord (7.0.5.1) lib/active_record/suppressor.rb:50:in `save'
app/services/user_updater.rb:242:in `block in update'
activerecord (7.0.5.1) lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
activesupport (7.0.5.1) lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
activesupport (7.0.5.1) lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
activesupport (7.0.5.1) lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
activesupport (7.0.5.1) lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
activerecord (7.0.5.1) lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
activerecord (7.0.5.1) lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
activerecord (7.0.5.1) lib/active_record/transactions.rb:209:in `transaction'
app/services/user_updater.rb:197:in `update'
app/controllers/users_controller.rb:250:in `block in update'
app/controllers/application_controller.rb:748:in `json_result'
app/controllers/users_controller.rb:244:in `update'
actionpack (7.0.5.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.5.1) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.0.5.1) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
app/controllers/application_controller.rb:420:in `block in with_resolved_locale'
i18n (1.14.1) lib/i18n.rb:322:in `with_locale'
app/controllers/application_controller.rb:420:in `with_resolved_locale'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.5.1) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.5.1) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.5.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.5.1) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.5.1) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.5.1) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.5.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.5.1) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.5.1) lib/action_view/rendering.rb:39:in `process'
rack-mini-profiler (3.1.1) lib/mini_profiler/profiling_methods.rb:111:in `block in profile_method'  
actionpack (7.0.5.1) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.5.1) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.5.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.5.1) lib/action_dispatch/routing/route_set.rb:852:in `call'
lib/middleware/omniauth_bypass_middleware.rb:74:in `call'
rack (2.2.8) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.8) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.8) lib/rack/head.rb:12:in `call'
actionpack (7.0.5.1) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:389:in `call'
lib/middleware/gtm_script_nonce_injector.rb:10:in `call'
config/initializers/008-rack-cors.rb:24:in `call'
rack (2.2.8) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.8) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/cookies.rb:704:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.5.1) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.5.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
logster (2.12.2) lib/logster/middleware/reporter.rb:43:in `call'
railties (7.0.5.1) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.5.1) lib/rails/rack/logger.rb:27:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
rack (2.2.8) lib/rack/method_override.rb:24:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
rack (2.2.8) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.5.1) lib/action_dispatch/middleware/host_authorization.rb:131:in `call'
rack-mini-profiler (3.1.1) lib/mini_profiler.rb:413:in `call'
message_bus (4.3.7) lib/message_bus/rack/middleware.rb:60:in `call'
lib/middleware/request_tracker.rb:233:in `call'
railties (7.0.5.1) lib/rails/engine.rb:530:in `call'
railties (7.0.5.1) lib/rails/

Removing the regex from Watched Words > Link fixes the issue. However, that means this issue is still unresolved:

Note that the regex is valid according to the ECMA 2018 standard, but maybe not by Ruby’s regex standard?

The regex also works as expected for posts on the forum.

إعجاب واحد (1)