Key :myself not found in: %{__changed__: %{__context__ ...}

After upgrading to liveview 0.17.9 and surface 0.7.3 I started getting this error:

22:05:34.839 [error] #PID<0.658.0> running LeadmgrWeb.Endpoint (connection #PID<0.657.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /dash
** (exit) an exception was raised:
    ** (KeyError) key :myself not found in: %{__changed__: %{__context__: true, id: true, inner_content: true, live_action: true, role: true, socket: true, unassigned_leads: true, user: true}, __context__: %{}, flash: %{}, id: nil, inner_content: %Phoenix.LiveView.Rendered{dynamic: ...}}
        (leadmgr 0.1.0) lib/leadmgr_web/live/components/nav_bar.sface:1: anonymous fn/2 in LeadmgrWeb.Live.NavBar."render (overridable 1)"/1
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/diff.ex:494: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
        (elixir 1.13.2) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/diff.ex:138: Phoenix.LiveView.Diff.render/3
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/static.ex:244: Phoenix.LiveView.Static.to_rendered_content_tag/4
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/static.ex:126: Phoenix.LiveView.Static.render/3
        (phoenix_live_view 0.17.9) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
        (phoenix 1.6.7) lib/phoenix/router.ex:355: Phoenix.Router.__call__/2
        (leadmgr 0.1.0) lib/leadmgr_web/endpoint.ex:1: LeadmgrWeb.Endpoint.plug_builder_call/2
        (leadmgr 0.1.0) lib/plug/debugger.ex:136: LeadmgrWeb.Endpoint."call (overridable 3)"/2
        (leadmgr 0.1.0) lib/leadmgr_web/endpoint.ex:1: LeadmgrWeb.Endpoint."call (overridable 4)"/2
        (leadmgr 0.1.0) lib/plug/debugger.ex:136: LeadmgrWeb.Endpoint.call/2
        (phoenix 1.6.7) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.9.0) /home/serge/tmp/dsavvy-leadmgr/leadmgr/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.9.0) /home/serge/tmp/dsavvy-leadmgr/leadmgr/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
        (cowboy 2.9.0) /home/serge/tmp/dsavvy-leadmgr/leadmgr/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
        (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3 []

The nav_bar.sface page is this:

<header class="w-full">
  <nav class="nav-bar">
    <img src={Routes.static_path(@socket, "/images/logo.gif")} alt="DS logo" class="logo">
    <div class="session-bar">
      <Status id="status-ind" live={true}/>
      {#if @user}
        <div class="signed" x-data="{ mm_show: false }">
          <button class="expand common" @click="mm_show = !mm_show">
            <i class="fas fa-user"></i> {@user.email}
          </button>
          <div class="drop" x-show="mm_show" @click.outside="mm_show = false" x-transition>
            <div class="py-1">
              <Link to={Routes.live_path(@socket, App.Live.Dashboard)} class="link link-row">
                <i class="fas fa-table"></i> <span>Dashboard</span>
              </Link>

              {#if @role && @role == "admin" or @role == "sysadmin"}
                <AdminMenu id="admin-menu"/>
              {/if}

              <Link to={Routes.live_path(@socket, App.Live.Settings)} class="link  link-row">
                <i class="fas fa-user-cog"></i> <span>User Profile</span>
              </Link>

              <Link to={Routes.session_path(@socket, :sign_out)} opts={data: [confirm: "Are you sure you want to sign-out?"]} method={:delete} class="link sign-out link-row">
                <i class="fas fa-sign-out-alt"></i> <span>Sign out</span>
              </Link>
            </div>
          </div>
        </div>
      {#else}
        <div class="not-signed">
          <Link to={Routes.session_path(@socket, :sign_in)} class="link link-row">
            <i class="fas fa-sign-in-alt"></i> <span>Sign in</span>
          </Link>
        </div>
      {/if}
    </div>
  </nav>
  <div class="w-full h-1.5 bg-gradient-to-b from-gray-300 to-transparent"></div>
</header>

And the live.html.heex is:

<div class="flex flex-col justify-center items-center">
<%= live_component(App.Live.NavBar, assigns) %>
<%= @inner_content %>
</div>

Any idea where does the need for :myself comes into play?

Your problem is how you’re invoking your live component. You need to use the HEEx syntax (module, id are required assigns):

<.live_component module={App.Live.NavBar} id="some-unique-id" assign_val_1="some-value" assign_val_2={@some_assign}

You cannot pass assigns as an entire map like you are in the original, you need to pass each one individually (like the assign_val_1 and assign_val_2 in the above)

More reading: Phoenix.LiveComponent — Phoenix LiveView v0.20.2