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

tapioca dsl fails on Rails 6.1 models due to ActiveRecord::Encryption reference #1913

Closed
aalong-tr opened this issue Jun 3, 2024 · 3 comments · Fixed by #1928
Closed

tapioca dsl fails on Rails 6.1 models due to ActiveRecord::Encryption reference #1913

aalong-tr opened this issue Jun 3, 2024 · 3 comments · Fixed by #1928

Comments

@aalong-tr
Copy link

Repo with simple reproduction here: https://github.com/aalong-tr/tapioca-rails-6-encryption

Tapioca version 0.14.3 includes improvements from #1904 to better handle Rails 7 encrypted attribute behaviors. Unfortunately this logic references a constant that does not exist on Rails 6. As a result, the tapioca dsl command run against a Rails 6.1 application produces the error:

bundler: failed to load command: tapioca (/Users/drew/.rbenv/versions/3.1.4/bin/tapioca)
/Users/drew/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/tapioca-0.14.3/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb:72:in `type_for_activerecord_value': NameError: uninitialized constant ActiveRecord::Encryption (Parallel::UndumpableException)

          when ActiveRecord::Encryption::EncryptedAttributeType
                           ^^^^^^^^^^^^
Did you mean?  Exception
@KaanOzkan
Copy link
Contributor

Thanks for the issue. I believe Rails 6.1 will be EOL soon so I'm not sure if we should support this out of the box. In the meantime feel free to override the method and remove the reference in your application.

@swiknaba
Copy link

swiknaba commented Jun 14, 2024

For now, placing this in e.g. your config/application.rb file fixes the issue:

# https://github.com/Shopify/tapioca/issues/1913
module ActiveRecord
  module Encryption
    class EncryptedAttributeType; end # rubocop:disable Lint/EmptyClass
  end
end

Dropping support for a Rails version (that is not EOL since a long time) might be worth a major version jump?

@paracycle
Copy link
Member

@swiknaba Rails 6.1 has been EOL since Rails 7.1 was released in October 2023 based on the maintenance policy of Rails:

The current release series and the next most recent one will receive patches and new versions in case of a security issue.

The core team has chosen to continue doing security releases for 6.1 series, as an exception, but that doesn't mean it is a supported version.

Tapioca follows the Rails and Ruby support schedules very closely, we drop official support for any versions that are no longer supported.

We enforce minimum versions of Ruby using the required_ruby_version in the gemspec, and we could do something similar to the versions of Rails that we support (via a runtime check, though) and refuse to generate any Rails related DSL RBIs if the version doesn't match.

We have opted to not do that, and to allow folks on older Ruby versions to be able to use Tapioca, but we won't be testing against older versions and, thus, support for them is best effort.

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

Successfully merging a pull request may close this issue.

4 participants