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) <noreply@anthropic.com>
This commit is contained in:
Guarzo
2026-08-01 19:03:01 +00:00
co-authored by Claude Opus 5
parent b7ddbc486a
commit 789d4fa884
+8 -1
View File
@@ -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