fix: preload associations in get_path!/1 to prevent NotLoaded crash
Some checks failed
Build and Push / Build and Push Docker Image (push) Has been cancelled

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.
This commit is contained in:
Graham McIntire 2026-08-05 08:37:55 -05:00
parent 5d16cf233e
commit ba9de7a522

View file

@ -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