Apipie:cache:index NoMethodError

Problem:
When running foreman-rake apipie:cache:index (from upgrade instructions or from the theforeman/foreman module), I receive the following error:

NoMethodError: undefined method 'rebuild_methods' for #<Class:0x000000077f03d0>
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/dynamic_matchers.rb:26:in 'method_missing'
/usr/share/foreman/app/models/host/managed.rb:490:in 'valid_rebuild_only_values'
/usr/share/foreman/config/initializers/apipie.rb:25:in 'block (2 levels) in <top (required)>'
/usr/share/foreman/config/initializers/apipie.rb:33:in 'call'
/usr/share/foreman/config/initializers/apipie.rb:33:in 'block (3 levels) in <top (required)>'
/usr/share/foreman/config/initializers/apipie.rb:33:in 'each'
/usr/share/foreman/config/initializers/apipie.rb:33:in 'map'
/usr/share/foreman/config/initializers/apipie.rb:33:in 'block (2 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/application.rb:365:in 'call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/application.rb:365:in 'translate'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/method_description.rb:131:in 'block in method_apis_to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/method_description.rb:127:in 'each'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/method_description.rb:127:in 'each'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/method_description.rb:127:in 'collect'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/method_description.rb:127:in 'method_apis_to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/method_description.rb:149:in 'to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/resource_description.rb:99:in 'block in to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/resource_description.rb:99:in 'each'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/resource_description.rb:99:in 'collect'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/resource_description.rb:99:in 'to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/application.rb:264:in 'block in to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/application.rb:263:in 'each'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/application.rb:263:in 'inject'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/application.rb:263:in 'to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/apipie/apipie_module.rb:13:in 'to_json'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/tasks/apipie.rake:77:in 'block (4 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/tasks/apipie.rake:66:in 'each'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/tasks/apipie.rake:66:in 'block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/tasks/apipie.rake:192:in 'with_loaded_documentation'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.6/lib/tasks/apipie.rake:64:in 'block (2 levels) in <top (required)>'
/usr/share/foreman/lib/tasks/apipie.rake:6:in 'block (2 levels) in <top (required)>'
Tasks: TOP => apipie:cache
(See full trace by running task with --trace)
2018-05-02 14:44:19 -0700 | Started
2018-05-02 14:44:24 -0700 | Documents loaded...
2018-05-02 14:44:24 -0700 | Processing docs for

Expected outcome:
No error

Foreman and Proxy versions:
Stock install of 1.16.1 using theforeman/foreman

Foreman and Proxy plugin versions:
No plugins

Other relevant data:
This occurred when trying to run an upgrade from 1.16.1 to 1.17, but it’s also occurring on a 1.16.1 install that’s never touched 1.17.

Do you have unattended set to false in the settings by any chance?

Yeah, I do have unattended set to false in settings.yaml, is that not a supported setup?

It is, but looks like there is a bug that causes this task to fail when unattended is false. Please open an issue on our issue tracker so that we can correct it.
As a workaround, you can set it to true just for running this task and reset it to false afterwards.

All set, thanks!

https://projects.theforeman.org/issues/23536