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

Setting a controller base class that uses http_basic_authenticate_with breaks bin/rails assets:precompile #118

Open
collimarco opened this issue May 12, 2024 · 2 comments

Comments

@collimarco
Copy link

Start with an application that is working fine and a docker image that is building successfully.

The application already has a Admin::AdminController that looks like this:

class Admin::AdminController < ApplicationController
  layout 'admin'
  http_basic_authenticate_with name: 'admin', password: Rails.application.credentials.admin_password, realm: 'Admin'
end

Then add this gem and add this line to an initializer:

MissionControl::Jobs.base_controller_class = "Admin::AdminController"

Or, alternatively, add this line to config/application.rb:

config.mission_control.jobs.base_controller_class = "Admin::AdminController"

Once you add that line of configuration, you start getting this error when you try to build the Docker image:

 > [10/10] RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile:
3.508 bin/rails aborted!
3.509 ArgumentError: Expected password: to be a String, got NilClass (ArgumentError)
3.509 
3.509             raise ArgumentError, "Expected password: to be a String, got #{password.class}" unless password.is_a?(String)
3.509                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3.509 /app/app/controllers/admin/admin_controller.rb:3:in `<class:AdminController>'
3.509 /app/app/controllers/admin/admin_controller.rb:1:in `<main>'
3.509 /app/config/environment.rb:5:in `<main>'
3.510 Tasks: TOP => environment

Is that configuration of mission_control causing an eager loading of controller file or something?
Or it's causing the controller file to be loaded before credentials are fully loaded?

Any solution?

@smitssjors
Copy link

This might help rails/rails#51772.

@collimarco
Copy link
Author

@smitssjors Thanks for the help! I already moved to Devise also for admins... so I have solved in some way.

I was just curious about why that error for credentials is raised only when I set that controller as the base controller for mission control. When I normally use that controller, without mission control, the docker image compiled normally without errors.

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

2 participants