Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
honeypc opened this issue Aug 20, 2022 · 4 comments
Open

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

honeypc opened this issue Aug 20, 2022 · 4 comments

Comments

@honeypc
Copy link

honeypc commented Aug 20, 2022

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
@akodkod
Copy link

akodkod commented Dec 5, 2022

+1

1 similar comment
@arinchoi03
Copy link

+1

@rhian-cs
Copy link

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.

@demccormack
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants