How can "no function clause matching MyAppWeb.SomethingLive.mount/3" happen?

Sometimes I can see in AppSignal for our app that there’s an ** (FunctionClauseError) no function clause matching in MyAppWeb.SomethingLive.mount/3

This is the setup:

# router.ex
live "/something/:id", SomethingLive
# something_live.ex
def mount(%{"id" => id}, session, socket) do
  # ...
end

And I can’t figure out how can that mount/3 function be reached without the id param being set.

Does anybody have an idea?

Thanks a lot.

1 Like

Without more context, it’s really hard to diagnose if that is absolutely-for-sure the only route for /something. Is there a guard clause on def mount or other pattern matches in the head you didn’t include in your example? Something like when is_binary(id) (not that it would ever be anything other than a string, just an example). What does the “given/received” part of the error message say?

There’s no guard. But I think @empanacho may be onto something. I feel like there’s some glitch happening with some live_redirect somewhere. But I don’t know how to simulate it, or get more info.