[bug] Crash when streaming out to Sockets #887

Open
opened 2025-03-21 01:35:07 +00:00 by Oneric · 0 comments
Member

Your setup

From source

Extra details

Alpine 3.21

Version

current master (74182abb5b)

PostgreSQL version

17

What is going wrong?

Every other day or so an error like the following shows up in my logs. I’m not too familiar with the weboscket code and not sure what consequences it has

2025-03-20 10:28:38.373 [error] Process #PID<0.58511.0> on node :akkoma@localhost raised an exception
** (KeyError) key :ap_id not found in: nil

If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
    (pleroma 3.15.2-wf-66-g34fdf125-u74182abb5-trunk) lib/pleroma/web/mastodon_api/views/conversation_view.ex:27: Pleroma.Web.MastodonAPI.ConversationView.render/2
    (pleroma 3.15.2-wf-66-g34fdf125-u74182abb5-trunk) lib/pleroma/web/views/streamer_view.ex:118: Pleroma.Web.StreamerView.render/3
    (pleroma 3.15.2-wf-66-g34fdf125-u74182abb5-trunk) lib/pleroma/web/streamer.ex:310: Pleroma.Web.Streamer.push_to_socket/2

For future reference here are the lines showing up in the stacktrace:

# lib/pleroma/web/mastodon_api/views/conversation_view.ex
  def render("participation.json", %{participation: participation, for: user}) do
    participation = Repo.preload(participation, conversation: [], recipients: [])

    last_activity_id =
      with nil <- participation.last_activity_id do
        ActivityPub.fetch_latest_direct_activity_id_for_context(
          participation.conversation.ap_id,   # <-----
          %{
            user: user,
            blocking_user: user
          }
        )
      end


# lib/pleroma/web/views/streamer_view.ex
  def render("conversation.json", %Participation{} = participation, topic) do
    %{
      stream: [topic],
      event: "conversation",
      payload:
        Pleroma.Web.MastodonAPI.ConversationView.render("participation.json", %{  # <------
          participation: participation,
          for: participation.user
        })
        |> Jason.encode!()
    }
    |> Jason.encode!()
  end


# lib/pleroma/web/streamer.ex
  defp push_to_socket(topic, %Participation{} = participation) do
    rendered = StreamerView.render("conversation.json", participation, topic)  # <------

    Registry.dispatch(@registry, topic, fn list ->

Severity

I can manage

Have you searched for this issue?

  • I have double-checked and have not found this issue mentioned anywhere.
### Your setup From source ### Extra details Alpine 3.21 ### Version current master (74182abb5b4b1186e4c68c426ad6ee680ebc804d) ### PostgreSQL version 17 ### What is going wrong? Every other day or so an error like the following shows up in my logs. I’m not too familiar with the weboscket code and not sure what consequences it has ``` 2025-03-20 10:28:38.373 [error] Process #PID<0.58511.0> on node :akkoma@localhost raised an exception ** (KeyError) key :ap_id not found in: nil If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map (pleroma 3.15.2-wf-66-g34fdf125-u74182abb5-trunk) lib/pleroma/web/mastodon_api/views/conversation_view.ex:27: Pleroma.Web.MastodonAPI.ConversationView.render/2 (pleroma 3.15.2-wf-66-g34fdf125-u74182abb5-trunk) lib/pleroma/web/views/streamer_view.ex:118: Pleroma.Web.StreamerView.render/3 (pleroma 3.15.2-wf-66-g34fdf125-u74182abb5-trunk) lib/pleroma/web/streamer.ex:310: Pleroma.Web.Streamer.push_to_socket/2 ``` For future reference here are the lines showing up in the stacktrace: ```elixir # lib/pleroma/web/mastodon_api/views/conversation_view.ex def render("participation.json", %{participation: participation, for: user}) do participation = Repo.preload(participation, conversation: [], recipients: []) last_activity_id = with nil <- participation.last_activity_id do ActivityPub.fetch_latest_direct_activity_id_for_context( participation.conversation.ap_id, # <----- %{ user: user, blocking_user: user } ) end # lib/pleroma/web/views/streamer_view.ex def render("conversation.json", %Participation{} = participation, topic) do %{ stream: [topic], event: "conversation", payload: Pleroma.Web.MastodonAPI.ConversationView.render("participation.json", %{ # <------ participation: participation, for: participation.user }) |> Jason.encode!() } |> Jason.encode!() end # lib/pleroma/web/streamer.ex defp push_to_socket(topic, %Participation{} = participation) do rendered = StreamerView.render("conversation.json", participation, topic) # <------ Registry.dispatch(@registry, topic, fn list -> ``` ### Severity I can manage ### Have you searched for this issue? - [x] I have double-checked and have not found this issue mentioned anywhere.
Oneric added the
bug
label 2025-03-21 01:35:07 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: AkkomaGang/akkoma#887
No description provided.