LemmyNet/lemmy · error

Private message is not part of community

Error message

Private message is not part of community

What it means

Protocol validation error in Delete::community: the Delete activity's object resolves to a PrivateMessage, which does not belong to any community, so resolving the owning community fails. It fires when a received Delete activity targets a private message via this community-scoped verification path; the input at fault is the activity's `object` field referencing a private message.

Source

Thrown at crates/apub/activities/src/protocol/deletion/delete.rs:66

  /// Nonstandard field denoting that the replies to an `Object` should be removed along with the
  /// `Object`. Only valid for `Pages` and `Notes`.
  // See here for discussion of this:
  // https://activitypub.space/topic/78/deleting-a-post-vs-deleting-an-entire-comment-tree
  pub(crate) with_replies: Option<bool>,
}

impl InCommunity for Delete {
  async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
    let community_id = match DeletableObjects::read_from_db(self.object.id(), context).await? {
      DeletableObjects::Community(c) => c.id,
      DeletableObjects::Comment(c) => {
        let post = Post::read(&mut context.pool(), c.post_id).await?;
        post.community_id
      }
      DeletableObjects::Post(p) => p.community_id,
      DeletableObjects::Person(_) => return Err(anyhow!("Person is not part of community").into()),
      DeletableObjects::PrivateMessage(_) => {
        return Err(anyhow!("Private message is not part of community").into());
      }
    };
    let community = Community::read(&mut context.pool(), community_id).await?;
    if let Some(audience) = &self.audience {
      verify_urls_match(audience.inner(), community.ap_id.inner())?;
    }
    Ok(community.into())
  }
}

impl Id for Delete {
  fn id(&self) -> &Url {
    &self.id
  }
}

View on GitHub (pinned to 439734dd63)

Solutions

  1. Route private-message deletions through a dedicated handler that skips community verification.
  2. Verify senders address private-message Deletes outside the InCommunity flow.
  3. Add an explicit match arm for private messages before requiring a community id.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/apub/activities/src/protocol/deletion/delete.rs:66 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of LemmyNet/lemmy@439734dd63 (2026-09-06). Data as JSON: /api/errors/e8abefdf93f54c8a. Report an issue: GitHub.