Skip to content

Phoenix router scopes causing binary_to_atom exceptions #360

@dmarkow

Description

@dmarkow

I have a standard Phoenix LiveView app. My router has some nested scopes:

# router.ex
scope "/", ApiWeb do
  scope "/admin", AdminLive do
    scope "/affiliation-types", AffiliationTypes do
      # live view routes
    end
    scope "/agreements", Agreements do
      # live view routes
    end
  end

  # a bunch more scopes

  scope "/ar", ARLive do
    live "/quickbooks", Quickbooks, :index
  end
end

If I hover over something in the Quickbooks line, I get a "Request textDocument/hover failed" pop-up repeatedly in VS Code/cursor. The logs show:

2026-02-06 05:54:52.895 [info] [Error - 5:54:52 AM] Request textDocument/hover failed.
2026-02-06 05:54:52.896 [info]   Message: ** (ErlangError) Erlang error: {:exception, :system_limit, [{:erlang, :binary_to_atom, ["Elixir.ApiWeb.AdminLive.AffiliationTypes.Agreements.Audits.BillingPositions.Checklists.Devices.FeeSchedules.KPIs.Offices.PlanTypes.PracticeAreas.Prompts.Resources.Routes.SalesStages.Skus.SocialMediaAccounts.Tags.Templates.TenTouches.Uploads.Users.ARLive.Quickbooks", :utf8], [error_info: %{module: :erl_erts_errors}]}, {:elixir_aliases, :concat, 1, [file: ~c"src/elixir_aliases.erl", line: 175]}, {XPEngine.CodeIntelligence.Entity, :maybe_prepend_phoenix_scope_module, 3, [file: ~c"lib/engine/code_intelligence/entity.ex", line: 269]}, {XPEngine.CodeIntelligence.Entity, :resolve_module, 4, [file: ~c"lib/engine/code_intelligence/entity.ex", line: 217]}, {XPEngine.CodeIntelligence.Entity, :resolve, 2, [file: ~c"lib/engine/code_intelligence/entity.ex", line: 41]}, {XPEngine, :resolve_entity, 2, []}]}
    (kernel 10.2.7.1) erpc.erl:1368: :erpc.call/5
    (xp_expert 0.1.0-80900e5) lib/expert/provider/handlers/hover.ex:29: XPExpert.Provider.Handlers.Hover.handle/1
    (xp_expert 0.1.0-80900e5) lib/expert.ex:119: XPExpert.handle_request/2
    (xp_gen_lsp 0.11.3) lib/gen_lsp.ex:390: anonymous fn/2 in XPGenLSP.loop/3
    (xp_telemetry 1.3.0) /home/runner/work/expert/expert/apps/expert/deps/telemetry/src/telemetry.erl:324: :xp_telemetry.span/3
    (xp_gen_lsp 0.11.3) lib/gen_lsp.ex:389: anonymous fn/5 in XPGenLSP.loop/3
    (xp_gen_lsp 0.11.3) lib/gen_lsp.ex:559: anonymous fn/4 in XPGenLSP.attempt/4
    (elixir 1.17.3) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2

It looks like it's trying to make an atom out of ALL of the previous scopes combined. So it should be converting Elixir.ApiWeb.ARLive.Quickbooks to an atom, it's instead converting Elixir.ApiWeb.AdminLive.AffiliationTypes.Agreements.Audits.BillingPositions.Checklists.Devices.FeeSchedules.KPIs.Offices.PlanTypes.PracticeAreas.Prompts.Resources.Routes.SalesStages.Skus.SocialMediaAccounts.Tags.Templates.TenTouches.Uploads.Users.ARLive.Quickbooks.

Also, if I hover over anything past the first set of nested scopes, the hover doesn't show anything (e.g. Elixir.ApiWeb.AdminLive.AffiliationTypes works fine, since there are no previous sibling scopes getting mixed in, but if I hover over Elixir.ApiWeb.AdminLive.Agreements, it doesn't work because it's inserting AffiliationTypes into that string)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions