rails / mission_control-jobs

Dashboard and Active Job extensions to operate and troubleshoot background jobs
MIT License
611 stars 71 forks source link

Navigation links are broken (?) #183

Closed julianrubisch closed 2 weeks ago

julianrubisch commented 3 weeks ago

As I'm migrating to solid_queue in an application, I also switched to mission_control-jobs. However, it creates navigation links that are complete nonsense:

CleanShot 2024-10-30 at 16 12 12@2x

Forgive me for not being more specific - I normally try to come up with more detailed error descriptions, but even after drilling into the source I didn't get a clue what's going on. I've confirmed that the application is correctly added to MissionControl::Jobs.applications, but all the application_* path helpers seem to output nonsense, which points at a namespace collision maybe? That's my only wild guess.

Also attempts to create an MVCE have failed.

My hope is that somebody has experienced something similar and/or might know what the issue could be.

rosa commented 3 weeks ago

That's so strange! What version are you using? Also, are you configuring MissionControl::Jobs.applications in any way or just letting it use the default?

julianrubisch commented 3 weeks ago

Hi @rosa, thanks for responding!

everything's in default mode, I've just added a base controller so as not to run into conflicts:

# application.rb
config.mission_control.jobs.base_controller_class = "MissionControl::BaseController"

# app/controllers/mission_control/base_controller.rb  
module MissionControl
  class BaseController < ActionController::Base
    protect_from_forgery with: :exception
  end
end  

versions:

  * mission_control-jobs (0.3.3)
        Summary: Operational controls for Active Job
        Homepage: https://github.com/rails/mission_control-jobs
        Source Code: https://github.com/rails/mission_control-jobs
        Path: /Users/jrubisch/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/mission_control-jobs-0.3.3
  * solid_queue (1.0.0)
        Summary: Database-backed Active Job backend.
        Homepage: https://github.com/rails/solid_queue
        Source Code: https://github.com/rails/solid_queue
        Path: /Users/jrubisch/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/solid_queue-1.0.0        

maybe worth noting, the actual routes (i.e. /jobs/applications/myapp/scheduled/jobs?server_id=solid_queue etc. do work. it's just that I can't navigate to them

rosa commented 3 weeks ago

Thanks a lot for these details, @julianrubisch! I assume you're also mounting the engine normally, in your routes just as

mount MissionControl::Jobs::Engine, at: "/jobs"
julianrubisch commented 3 weeks ago

Exactly. Apologies again for being clueless. I will try to dig deeper and come up with something more actionable.

FWIW, all the path helpers are also correctly reported w/ rails routes

julianrubisch commented 2 weeks ago

Okay, I'm aggregating more data ... it does seem like there's some kind of isolation issue. It seems to boil down to this:

irb(#<#<Class:0x0000000171c1ac88>...):016> queues_path
=> "/jobs/assets?action=index&controller=mission_control%2Fjobs%2Fqueues&server_id=solid_queue"
irb(#<#<Class:0x0000000171c1ac88>...):016> MissionControl::Jobs::Engine.routes.url_helpers.queues_path
=> "/jobs/queues" 

called from inside NavigationHelper#navigation_section. FWIW I've removed every other engine from the Gemfile. I also double checked that there are no name collisions in the RouteSet.

The Rails version is 7.2.2

julianrubisch commented 2 weeks ago

okay, it seems like this solves the problem: https://stackoverflow.com/a/65023594 🙈

I indeed had such an include in my ApplicationHelper. Still quite at a loss why that would break things, but good to know ✌

rosa commented 2 weeks ago

Oh wow! 🤯 I had never encountered this before! Incredible find 🙇‍♀️