mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Conslidate log messages for object fetcher failures and leverage Logger.metadata
This commit is contained in:
parent
6c9929b809
commit
becb070603
2 changed files with 27 additions and 20 deletions
|
@ -72,23 +72,25 @@ defmodule Pleroma.Object.Fetcher do
|
||||||
{:object, data, Object.normalize(activity, fetch: false)} do
|
{:object, data, Object.normalize(activity, fetch: false)} do
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
else
|
else
|
||||||
{:allowed_depth, false} ->
|
{:allowed_depth, false} = e ->
|
||||||
|
log_fetch_error(id, e)
|
||||||
{:error, "Max thread distance exceeded."}
|
{:error, "Max thread distance exceeded."}
|
||||||
|
|
||||||
{:containment, e} ->
|
{:containment, reason} = e ->
|
||||||
Logger.error("Error while fetching #{id}: Object containment failed. #{inspect(e)}")
|
log_fetch_error(id, e)
|
||||||
{:error, e}
|
{:error, reason}
|
||||||
|
|
||||||
{:transmogrifier, {:error, {:reject, e}}} ->
|
{:transmogrifier, {:error, {:reject, reason}}} = e ->
|
||||||
Logger.error("Rejected #{id} while fetching: #{inspect(e)}")
|
log_fetch_error(id, e)
|
||||||
{:reject, e}
|
{:reject, reason}
|
||||||
|
|
||||||
{:transmogrifier, {:reject, e}} ->
|
{:transmogrifier, {:reject, reason}} = e ->
|
||||||
Logger.error("Rejected #{id} while fetching: #{inspect(e)}")
|
log_fetch_error(id, e)
|
||||||
{:reject, e}
|
{:reject, reason}
|
||||||
|
|
||||||
{:transmogrifier, _} = e ->
|
{:transmogrifier, reason} = e ->
|
||||||
{:error, e}
|
log_fetch_error(id, e)
|
||||||
|
{:error, reason}
|
||||||
|
|
||||||
{:object, data, nil} ->
|
{:object, data, nil} ->
|
||||||
reinject_object(%Object{}, data)
|
reinject_object(%Object{}, data)
|
||||||
|
@ -99,16 +101,21 @@ defmodule Pleroma.Object.Fetcher do
|
||||||
{:fetch_object, %Object{} = object} ->
|
{:fetch_object, %Object{} = object} ->
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
|
|
||||||
{:fetch, {:error, error}} ->
|
{:fetch, {:error, reason}} = e ->
|
||||||
Logger.error("Error while fetching #{id}: #{inspect(error)}")
|
log_fetch_error(id, e)
|
||||||
{:error, error}
|
{:error, reason}
|
||||||
|
|
||||||
e ->
|
e ->
|
||||||
Logger.error("Error while fetching #{id}: #{inspect(e)}")
|
log_fetch_error(id, e)
|
||||||
{:error, e}
|
{:error, e}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp log_fetch_error(id, error) do
|
||||||
|
Logger.metadata([object: id])
|
||||||
|
Logger.error("Object rejected while fetching #{id} #{inspect(error)}")
|
||||||
|
end
|
||||||
|
|
||||||
defp prepare_activity_params(data) do
|
defp prepare_activity_params(data) do
|
||||||
%{
|
%{
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
|
|
|
@ -132,7 +132,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
assert {:ok, activity} = Transmogrifier.handle_incoming(message)
|
assert {:ok, activity} = Transmogrifier.handle_incoming(message)
|
||||||
object = Object.normalize(activity)
|
object = Object.normalize(activity)
|
||||||
assert [%{"type" => "Mention"}, %{"type" => "Link"}] = object.data["tag"]
|
assert [%{"type" => "Mention"}, %{"type" => "Link"}] = object.data["tag"]
|
||||||
end) =~ "Error while fetching"
|
end) =~ "Object rejected while fetching"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it accepts quote posts" do
|
test "it accepts quote posts" do
|
||||||
|
@ -410,7 +410,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
assert capture_log(fn ->
|
assert capture_log(fn ->
|
||||||
{:error, _} = Transmogrifier.handle_incoming(data)
|
{:error, _} = Transmogrifier.handle_incoming(data)
|
||||||
end) =~ "Object containment failed"
|
end) =~ "Object rejected while fetching"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it rejects activities which reference objects that have an incorrect attribution (variant 1)" do
|
test "it rejects activities which reference objects that have an incorrect attribution (variant 1)" do
|
||||||
|
@ -425,7 +425,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
assert capture_log(fn ->
|
assert capture_log(fn ->
|
||||||
{:error, _} = Transmogrifier.handle_incoming(data)
|
{:error, _} = Transmogrifier.handle_incoming(data)
|
||||||
end) =~ "Object containment failed"
|
end) =~ "Object rejected while fetching"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it rejects activities which reference objects that have an incorrect attribution (variant 2)" do
|
test "it rejects activities which reference objects that have an incorrect attribution (variant 2)" do
|
||||||
|
@ -440,7 +440,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
assert capture_log(fn ->
|
assert capture_log(fn ->
|
||||||
{:error, _} = Transmogrifier.handle_incoming(data)
|
{:error, _} = Transmogrifier.handle_incoming(data)
|
||||||
end) =~ "Object containment failed"
|
end) =~ "Object rejected while fetching"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue