From ba9de7a5228994c07f0f53de6b48d88788bfc906 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 5 Aug 2026 08:37:55 -0500 Subject: [PATCH] fix: preload associations in get_path!/1 to prevent NotLoaded crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RoverPathProfileWorker broadcasts {:rover_path_updated, path_id} after updating a path. handle_info fetches via get_path!/1 and splices into @paths, but get_path!/1 did not preload :rover_location — causing a KeyError on %Ecto.Association.NotLoaded{} when the template accessed location.id. Preload [:rover_location, :station, :mission] matching the pattern in list_paths/1 and path_live.ex. --- lib/microwaveprop/rover_planning.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/microwaveprop/rover_planning.ex b/lib/microwaveprop/rover_planning.ex index b41dc5ef..ebb626f4 100644 --- a/lib/microwaveprop/rover_planning.ex +++ b/lib/microwaveprop/rover_planning.ex @@ -124,7 +124,7 @@ defmodule Microwaveprop.RoverPlanning do @doc "Fetches a single path by id or raises Ecto.NoResultsError." @spec get_path!(Ecto.UUID.t()) :: Path.t() - def get_path!(id), do: Repo.get!(Path, id) + def get_path!(id), do: id |> Repo.get!(Path) |> Repo.preload([:rover_location, :station, :mission]) @doc """ Reconciles the path matrix for a mission against the current set of