O que pode estar causando erros 500 ao salvar preferências do usuário?

Encontrei outro bug estranho na minha instância do Discourse nos últimos dias. Não consigo salvar nenhuma preferência de usuário para meu próprio usuário administrador, recebo apenas erros 500. Parece ser o mesmo para qualquer solicitação PUT para u/[MEU_NOME_DE_USUÁRIO].json.

Também tentei repetir a mesma solicitação no Postman usando uma chave de API válida, mas isso também falhou:

Não vejo nenhum erro aparecendo em /logs também.

Outras contas de usuário não parecem ser afetadas, pelo menos as que tentei.

Atualizei o Discourse para a versão mais recente ontem, mas o problema já existia antes da atualização.

Alguma ideia de como posso continuar depurando isso?

Se você visitar /logs na sua instância do Discourse enquanto estiver logado como administrador, ele deverá mostrar mais detalhes sobre erros como este. Se você puder compartilhar o conteúdo das abas ‘info’ e ‘backtrace’ para o erro relevante, isso nos ajudará a rastrear o problema.

Editar: ah, vejo que você já olhou lá :thinking:. Você poderia verificar novamente se todos os tipos de erro estão habilitados no canto inferior esquerdo de /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 curtida