John_Shelby
Phoenix 1.7 upgrade - error: key :conn not found in: %{
Hello,
I have a problem after logging in to my app and I don’t know how to solve this error: key :conn not found in: %{__changed__: % in my_app_web/templates/layout/app.html.heex Has anyone encountered this before? I’m upgrading from phoenix from 1.6.9 to 1.7.0 and phoenix_live_view from 17.8 to 18.3.
I don’t know what I should have set wrong. I followed the upgrade instructions or also the video from Elixircast
I checked web.ex and everything from tutorials, but it seems ok.
Has anyone had the same problem please?
Any ideas? Thank you.
Need more information to solve a problem?
Most Liked
LostKobrakai
If you’re using LV you should have a root.html.heex and use that as root template. Leave just the pieces within <body> in app.html.heex, there rest goes into root.html.heex. Everything in the root template is not touched by LV, but everything within app.html can be. LV trying to manage head content however won’t go well. root.html.heex will always receive a @conn, but (if you stick to using it for LV and non-LV) app.html.heex will either have access to a @conn or @socket depending on the type of page. For all things related to links you can substitute them for MyAppWeb.Endpoint, which works for both types of pages.
smathy
Right, yes, that’s a difficult situation. What I think the problem here is is that you have @conn inside your heex template tags ({}), which is then being processed by LV as a tracked template var, and hence it’s looking for the :conn key in its internal __changed__ map (which it can’t find). If you look in a new 1.7 project’s root.html.heex you’ll see it’s now using the verified routes ~p sigil:
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
…so that should solve this problem, but I fear that’ll just lead you to the next, and the next, and the next.
smathy
Not answering your specific question here, but generally I find the best approach is to use the generator to create two new empty projects, one in the old version and one in the new version and use a diff of those two as a guide for what to change in your project.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex










