Skip to content

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

@collimarco

Description

@collimarco

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions