From 2ab072f94947ee7ee719eff86f012e6302eeeacd Mon Sep 17 00:00:00 2001 From: stwf Date: Thu, 24 Oct 2019 12:08:34 -0400 Subject: [PATCH 1/2] object fetcher error handling --- lib/pleroma/object/fetcher.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex index 7758cb90b..441ae8b65 100644 --- a/lib/pleroma/object/fetcher.ex +++ b/lib/pleroma/object/fetcher.ex @@ -90,6 +90,9 @@ def fetch_object_from_id(id, options \\ []) do {:fetch_object, %Object{} = object} -> {:ok, object} + {:fetch, {:error, error}} -> + {:error, error} + e -> e end @@ -110,6 +113,9 @@ def fetch_object_from_id!(id, options \\ []) do with {:ok, object} <- fetch_object_from_id(id, options) do object else + {:error, %Tesla.Mock.Error{}} -> + nil + e -> Logger.error("Error while fetching #{id}: #{inspect(e)}") nil @@ -170,6 +176,9 @@ def fetch_and_contain_remote_object_from_id(id) when is_binary(id) do {:scheme, _} -> {:error, "Unsupported URI scheme"} + {:error, e} -> + {:error, e} + e -> {:error, e} end From 5329b361ecb11bde79108f002dff94a3a3beb8ab Mon Sep 17 00:00:00 2001 From: stwf Date: Thu, 24 Oct 2019 12:48:17 -0400 Subject: [PATCH 2/2] fix test --- test/web/activity_pub/transmogrifier_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index ae56f8494..6f7e1da1f 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -720,7 +720,7 @@ test "it fails for incoming deletes with spoofed origin" do assert capture_log(fn -> :error = Transmogrifier.handle_incoming(data) end) =~ - "[error] Could not decode user at fetch http://mastodon.example.org/users/gargron, {:error, {:error, :nxdomain}}" + "[error] Could not decode user at fetch http://mastodon.example.org/users/gargron, {:error, :nxdomain}" assert Activity.get_by_id(activity.id) end