From 789d4fa8846ac7e20b210ef6aab3b0545ee261ef Mon Sep 17 00:00:00 2001 From: Guarzo Date: Sat, 1 Aug 2026 19:03:01 +0000 Subject: [PATCH] fix(map): stop MapRepo.get/2 masking all errors as :not_found MapRepo.get/2 flattened every error from Api.Map.by_id/1 into {:error, :not_found}. That turned infrastructure faults into a "map does not exist" signal: a DBConnection.OwnershipError in test surfaced as "Failed to load map state" -> "map not loaded" -> "Timeout waiting for map ... Check Map.Manager is running", pointing at Map.Manager (which was running fine) instead of the real cause. Keep the :not_found translation for a genuine Ash NotFound, and propagate + log anything else. Co-Authored-By: Claude Opus 5 (1M context) --- lib/wanderer_app/repositories/map_repo.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/wanderer_app/repositories/map_repo.ex b/lib/wanderer_app/repositories/map_repo.ex index 9a06da84..b196c48f 100644 --- a/lib/wanderer_app/repositories/map_repo.ex +++ b/lib/wanderer_app/repositories/map_repo.ex @@ -21,8 +21,15 @@ defmodule WandererApp.MapRepo do {:ok, map} -> map |> load_relationships(relationships) - _ -> + {:error, %Ash.Error.Query.NotFound{}} -> {:error, :not_found} + + {:error, reason} = error -> + # Previously every error was flattened into {:error, :not_found}, which + # masked infrastructure faults (e.g. DBConnection ownership errors) as + # "map does not exist" and made them very hard to diagnose. + Logger.error("MapRepo.get failed for map #{inspect(map_id)}: #{inspect(reason)}") + error end end