annotate_models icon indicating copy to clipboard operation
annotate_models copied to clipboard

Unable to annotate: ActiveRecord::Encryption::Errors::Decryption

Open honeypc opened this issue 3 years ago • 4 comments

I'm using the ActiveRecord::Encryption on column email and got this issue. Please help me to the right config Thanks,

Commands

Unable to annotate app/models/user.rb: ActiveRecord::Encryption::Errors::Decryption
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/encryptor.rb:58:in `rescue in decrypt'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/encryptor.rb:52:in `decrypt'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/encrypted_attribute_type.rb:73:in `block in decrypt'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/scheme.rb:67:in `with_context'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/encrypted_attribute_type.rb:15:in `with_context'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/encrypted_attribute_type.rb:72:in `decrypt'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/encryption/encrypted_attribute_type.rb:31:in `deserialize'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activemodel-7.0.3.1/lib/active_model/attribute.rb:168:in `type_cast'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activemodel-7.0.3.1/lib/active_model/attribute.rb:43:in `value'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activemodel-7.0.3.1/lib/active_model/attribute_set.rb:33:in `block in to_hash'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/enumerable.rb:129:in `block in index_with'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/enumerable.rb:129:in `each'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/enumerable.rb:129:in `index_with'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activemodel-7.0.3.1/lib/active_model/attribute_set.rb:33:in `to_hash'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/model_schema.rb:471:in `column_defaults'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:115:in `schema_default'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:867:in `get_attributes'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:151:in `block in get_schema_info'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:149:in `each'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:149:in `get_schema_info'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:481:in `annotate'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:682:in `annotate_model_file'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:658:in `block in do_annotations'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:657:in `each'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:657:in `do_annotations'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/bin/annotate:31:in `<top (required)>'
	/Users/phuoctu/.rbenv/versions/3.1.2/bin/annotate:25:in `load'
	/Users/phuoctu/.rbenv/versions/3.1.2/bin/annotate:25:in `<main>'
Unable to annotate app/models/user.rb: no implicit conversion of nil into Array
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:682:in `concat'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:682:in `annotate_model_file'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:658:in `block in do_annotations'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:657:in `each'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/lib/annotate/annotate_models.rb:657:in `do_annotations'
	/Users/phuoctu/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/annotate-3.2.0/bin/annotate:31:in `<top (required)>'
	/Users/phuoctu/.rbenv/versions/3.1.2/bin/annotate:25:in `load'
	/Users/phuoctu/.rbenv/versions/3.1.2/bin/annotate:25:in `<main>'
Model files unchanged.

Version

  • annotate version: annotate-3.2.0
  • rails version: 3.1.2
  • ruby version: 7.0.3

honeypc avatar Aug 20 '22 04:08 honeypc

+1

akodkod avatar Dec 05 '22 16:12 akodkod

+1

arinchoi03 avatar Apr 11 '23 16:04 arinchoi03

I had this issue and for me it was because I had set a default value of "" to my encrypted column. Changing the type from:

t.string :error_message, null: false, default: ''

To:

t.string :error_message

solved it for me.

This might be an issue with ActiveRecord::Encryption but more investigation would be required.

rhian-cs avatar Oct 12 '23 01:10 rhian-cs

I have this problem too. It looks to me like a Rails upgrade will fix it. There is a fix for encrypted column defaults in Rails v7.1.1.

demccormack avatar Nov 16 '23 19:11 demccormack