La importación de Json falla con el método no definido `token='

Importing data via json_generic.rb currently fails with:

/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.3.2/lib/active_model/attribute_methods.rb:469:in `method_missing': undefined method `token=' for #<EmailToken:0x00005645c4df6618> (NoMethodError)
Did you mean?  token_hash

This previously worked in June 2021 – could the issue be related to this commit?

Here is the full traceback:

Traceback (most recent call last):
	84: from script/import_scripts/json_generic.rb:108:in `<main>'
	83: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
	82: from script/import_scripts/json_generic.rb:22:in `execute'
	81: from script/import_scripts/json_generic.rb:53:in `import_users'
	80: from /var/www/discourse/script/import_scripts/base.rb:264:in `create_users'
	79: from /var/www/discourse/script/import_scripts/base.rb:264:in `each'
	78: from /var/www/discourse/script/import_scripts/base.rb:276:in `block in create_users'
	77: from /var/www/discourse/script/import_scripts/base.rb:344:in `create_user'
	76: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:209:in `transaction'
	75: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
	74: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:308:in `within_new_transaction'
	73: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
	72: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
	71: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
	70: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
	69: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
	68: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:310:in `block in within_new_transaction'
	67: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
	66: from /var/www/discourse/script/import_scripts/base.rb:345:in `block in create_user'
	65: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/suppressor.rb:48:in `save!'
	64: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:302:in `save!'
	63: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
	62: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
	61: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
	60: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:302:in `block in save!'
	59: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/validations.rb:53:in `save!'
	58: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/persistence.rb:507:in `save!'
	57: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/timestamp.rb:126:in `create_or_update'
	56: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/callbacks.rb:457:in `create_or_update'
	55: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:824:in `_run_save_callbacks'
	54: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:137:in `run_callbacks'
	53: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
	52: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/autosave_association.rb:385:in `around_save_collection_association'
	51: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
	50: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/callbacks.rb:457:in `block in create_or_update'
	49: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/persistence.rb:900:in `create_or_update'
	48: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/timestamp.rb:108:in `_create_record'
	47: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/callbacks.rb:461:in `_create_record'
	46: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:824:in `_run_create_callbacks'
	45: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:107:in `run_callbacks'
	44: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:516:in `invoke_after'
	43: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:516:in `each'
	42: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:516:in `block in invoke_after'
	41: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:235:in `block in halting_and_conditional'
	40: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:427:in `block in make_lambda'
	39: from /var/www/discourse/app/models/user.rb:1460:in `create_email_token'
	38: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_proxy.rb:364:in `create!'
	37: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/association.rb:209:in `create!'
	36: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/has_many_association.rb:137:in `_create_record'
	35: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:357:in `_create_record'
	34: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:134:in `transaction'
	33: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:209:in `transaction'
	32: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
	31: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:135:in `block in transaction'
	30: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:359:in `block in _create_record'
	29: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:285:in `add_to_target'
	28: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:460:in `replace_on_target'
	27: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:360:in `block (2 levels) in _create_record'
	26: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/has_many_association.rb:58:in `insert_record'
	25: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/associations/collection_association.rb:373:in `insert_record'
	24: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/suppressor.rb:48:in `save!'
	23: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:302:in `save!'
	22: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
	21: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
	20: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
	19: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/transactions.rb:302:in `block in save!'
	18: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/validations.rb:53:in `save!'
	17: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/validations.rb:84:in `perform_validations'
	16: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.3.2/lib/active_record/validations.rb:68:in `valid?'
	15: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.3.2/lib/active_model/validations.rb:337:in `valid?'
	14: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.3.2/lib/active_model/validations/callbacks.rb:117:in `run_validations!'
	13: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:824:in `_run_validation_callbacks'
	12: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:105:in `run_callbacks'
	11: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:512:in `invoke_before'
	10: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:512:in `each'
	 9: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:512:in `block in invoke_before'
	 8: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:180:in `block in halting_and_conditional'
	 7: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:603:in `block in default_terminator'
	 6: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:603:in `catch'
	 5: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
	 4: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:179:in `block (2 levels) in halting_and_conditional'
	 3: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:427:in `block in make_lambda'
	 2: from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3.2/lib/active_support/callbacks.rb:427:in `instance_exec'
	 1: from /var/www/discourse/app/models/email_token.rb:9:in `block in <class:EmailToken>'
/var/www/discourse/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.3.2/lib/active_model/attribute_methods.rb:469:in `method_missing': undefined method `token=' for #<EmailToken:0x000055fb6b4965f8> (NoMethodError)
Did you mean?  token_hash

Anyone else experiencing this? Or anything I am potentially missing something here?

Podría ser. Me sorprende un poco que json_generic haya funcionado alguna vez sin cambios. Dudo que se use muy a menudo. Si puedes averiguar cómo arreglarlo (¡sabías lo suficiente como para encontrar el commit que probablemente lo rompió!) y enviar una PR, apuesto a que sería aceptada, pero no tengo nada que decir al respecto.

Lamentablemente, parece que no podemos averiguar cómo solucionarlo. Pero lo que ayudó fue simplemente reconstruir el contenedor por completo. Así que no estoy seguro de qué causó el problema de nuestra parte, pero nuestro enfoque parece haberlo solucionado temporalmente. Disculpas por la posible falsa alarma.

Pero esto demuestra que json_generic todavía parece funcionar bien.

1 me gusta