Skip to content

Fix 55215 test failure #55227

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

Merged

Conversation

fabricerenard12
Copy link
Contributor

@fabricerenard12 fabricerenard12 commented Jun 23, 2025

Motivation / Background

Fixes #55215

Detail

This Pull Request adds require "action_controller" to railties/lib/rails/health_controller.rb, guaranteeing ActionController::Base is loaded before Rails::HealthController is defined and eliminating the NameError seen in #55215.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@rails-bot rails-bot bot added the railties label Jun 23, 2025
@skipkayhil
Copy link
Member

👋 hey @fabricerenard12, thanks for taking a stab at this! It looks like there's a real failure in CI, could you take a look?

@fabricerenard12 fabricerenard12 force-pushed the 55215_name_error_health_controller branch 2 times, most recently from 5f94ea6 to d3cbc72 Compare June 23, 2025 18:28
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "action_controller/railtie"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right fix is to require "action_controller` only so that all autoloads' are setup.
Requiring the railtie should be opt-in. In a normal Rails application this would not matter much, but in standalone scripts like Rails bug report templates (e.g. https://github.com/rails/rails/blob/05f0b1614d82424a7507caaec5cf701d3a8c2b21/guides/bug_report_templates/active_job.rb) we want to be able to choose which railtie to load.

@fabricerenard12 fabricerenard12 force-pushed the 55215_name_error_health_controller branch from d3cbc72 to b678354 Compare June 23, 2025 20:53
Copy link
Member

@Edouard-chin Edouard-chin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We we'll also need to modify the Rails::ApplicationController with the same fix https://github.com/rails/rails/blob/05f0b1614d82424a7507caaec5cf701d3a8c2b21/railties/lib/rails/application_controller.rb

It's the parent class of the PwaController which gets also eagerloaded. (it works right now without issue but if we end up swapping these two lines in the future it would fail the same way)

eager_autoload do
autoload :HealthController
autoload :PwaController
end
)

Thanks !

@fabricerenard12 fabricerenard12 force-pushed the 55215_name_error_health_controller branch from b678354 to e16893b Compare June 23, 2025 21:47
@fabricerenard12 fabricerenard12 force-pushed the 55215_name_error_health_controller branch from e16893b to 7b680f8 Compare June 23, 2025 22:01
Copy link
Member

@Edouard-chin Edouard-chin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ! Someone from the team with commit privilege will review and merge when they get the chance.

Thanks for your contribution !

@Edouard-chin Edouard-chin added the ready PRs ready to merge label Jun 23, 2025
@byroot byroot merged commit 4c803a2 into rails:main Jul 1, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
railties ready PRs ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NameError: uninitialized constant ActionController::Base for railties/lib/rails/health_controller.rb
4 participants