فشل استيراد Json مع الطريقة غير المعرفة `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?

قد يكون. أنا متفاجئ بعض الشيء من أن json_generic قد عمل في أي وقت مضى دون تغييرات. أشك في أنه يُستخدم كثيرًا. إذا تمكنت من معرفة كيفية إصلاحه (لقد عرفت ما يكفي للعثور على الالتزام الذي ربما كسره!) وتقديم طلب سحب (PR)، أراهن على قبوله، لكن ليس لدي أي رأي في ذلك.

لحسن الحظ، لم نتمكن من معرفة كيفية إصلاحه. لكن ما ساعد هو ببساطة إعادة بناء الحاوية بأكملها. لذلك لست متأكدًا مما تسبب في المشكلة من جانبنا، ولكن يبدو أن نهجنا قد أصلحها مؤقتًا. آسف على الإنذار الكاذب المحتمل.

ولكن ما يظهره هذا هو أن json_generic لا يزال يعمل بشكل جيد.

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