LemmyNet/lemmy · error

Object must have name or content

Error message

Object must have name or content

What it means

Validation error in Post::from_json: the incoming ActivityPub Page object has neither a `name` (title) nor usable `content` from which a title could be derived, so a required post title cannot be constructed. It fires when converting a federated post whose payload lacks both fields; the input at fault is the remote Page object's name/content.

Source

Thrown at crates/apub/objects/src/objects/post.rs:248

      .clone()
      .or_else(|| {
        // Posts coming from Mastodon or similar platforms don't have a title. Instead we take the
        // first line of the content and convert it from HTML to plaintext. We also remove mentions
        // of the community name.
        let c = page
          .content
          .as_deref()
          .map(StringReader::new)
          .map(|c| from_read_with_decorator(c, MAX_TITLE_LENGTH, TrivialDecorator::new()))?;
        c.unwrap_or_default().lines().next().map(|s| {
          s.replace(&format!("@{}", community.name), "")
            .trim()
            .to_string()
        })
      })
      .map(|n| remove_slurs(&n, &slur_regex))
      .map(|n| truncate_for_db(&n, MAX_TITLE_LENGTH))
      .ok_or_else(|| anyhow!("Object must have name or content"))?;

    let first_attachment = page.attachment.first();
    let url = if let Some(attachment) = first_attachment.cloned() {
      Some(attachment.url())
    } else if page.kind == PageType::Video {
      // we cant display videos directly, so insert a link to external video page
      Some(page.id.inner().clone())
    } else {
      None
    };

    let url_blocklist = get_url_blocklist(context).await?;

    let url = if let Some(url) = url {
      is_url_blocked(&url, &url_blocklist)?;
      is_valid_url(&url)?;
      if page.kind != PageType::Video {
        to_local_url(url.as_str(), context).await.or(Some(url))

View on GitHub (pinned to 439734dd63)

Solutions

  1. Reject the federated post as invalid; senders must include at least a name or content.
  2. Ask the source platform (e.g. Mastodon-like) to provide a title or non-empty content.
  3. Add leniency upstream: derive a placeholder title from attachments/summary instead of failing.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/apub/objects/src/objects/post.rs:248 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/186d31890b8dd516. Report an issue: GitHub.