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

ActiveRecord::RecordInvalid: Validation failed: Provider type translation missing: en.activerecord.errors.models.job_template.attributes.provider_type.uniq #120

Closed
ekohl opened this issue Dec 13, 2022 · 4 comments · Fixed by #133

Comments

@ekohl
Copy link
Member

ekohl commented Dec 13, 2022

When trying to seed on a fresh installation I get:

ActiveRecord::RecordInvalid: Validation failed: Provider type translation missing: en.activerecord.errors.models.job_template.attributes.provider_type.uniq
/home/ekohl/dev/foreman_leapp/db/seeds.d/10_leapp_preupgrade.rb:18:in `block (4 levels) in <main>'
@stejskalleos
Copy link
Contributor

How to reproduce:

🔴 Without Ansible:

# bundler.d/dev.rb
gem 'foreman_leapp', path: '/path/gem'

bundle exec rails db:migrate
bundle exec rails db:seed ==> fails

🟢 With Ansible:

# bundler.d/dev.rb
gem 'foreman_ansible', path: '/path/gem'
gem 'foreman_leapp', path: '/path/gem'

bundle exec rails db:migrate
bundle exec rails db:seed ==> works

Not sure why it's happening, ansible is set as dependency, need to investigate closer ..

@ekohl
Copy link
Member Author

ekohl commented Dec 16, 2022

Oh, that is interesting. I can confirm that bundle show does list foreman_ansible:

$ bundle info foreman_ansible
  * foreman_ansible (10.1.0)

So it's also not pulling in an ancient version.

Yet, when I add it to bundler it does load. That makes me think this code could be related:
https://github.com/theforeman/foreman/blob/34728aee6b213c68e56df7bb5e3b86ab194b2a33/config/application.rb#L29-L66

@ekohl
Copy link
Member Author

ekohl commented Jan 9, 2024

My theory is that bundler doesn't know to load the gem, somehow. If you list a gem in a Gemfile then there's an implicit require. I suspect that you can reproduce this by adding this:

gem 'foreman_ansible', require: false

We have this code in Foreman to declare a dependency as well:
https://github.com/theforeman/foreman/blob/6575dc039092bcb2bf5c9e2bc45139cb16f6e26e/app/registries/foreman/plugin.rb#L236-L248

Yet, I doubt its usefulness in the current form. One issue is the load order. If you first load foreman_leapp and then foreman_ansible the Plugin.find('foreman_ansible') code would fail.

Historical explanation why it makes sense to check the version: we have bundler_ext that discards the version checks that bundler does. However, we now also enforce the same dependencies via RPMs so that doesn't really make sense anymore.

But something like this could be a path to ensure the dependency is actually loaded. The version matcher should be made optional (and deprecated) while also adding support for declaring an optional dependency.

@evgeni
Copy link
Member

evgeni commented Jan 25, 2024

I've started hitting this in #133 too

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.

3 participants