Why are supposedly ActivityPub-federated Discourse threads inaccessible via external AP clients?

AI-generated summary

Users report that ActivityPub-federated Discourse threads are inaccessible via external AP clients like Mastodon, despite Discourse’s native AP integration. rokejulianlockhart demonstrates the issue using specific URLs that return 404s on Mastodon. icaria36 confirms the problem and notes it hinders interaction with federated posts outside one’s timeline. Initially suspected to be a Mastodon bug, further investigation reveals Discourse returns HTTP 400 when Mastodon sends an Accept header including text/html;q=0.1 — which Discourse interprets as non-compliant with the ActivityPub spec. angus clarifies that Discourse’s behavior follows the spec, which mandates strict application/ld+json for GET requests. However, Mastodon’s inclusion of text/html appears to be for fallback UX purposes. A fix is underway via discourse-activity-pub#219, and angus confirms resolution is imminent. The topic was initially mislabeled as a solution; users request it be moved to bug based on Mastodon’s findings here. Formatting issues in federated posts and accidental self-likes are also noted as secondary problems rokejulianlockhart.

Example

If I enter https://meta.discourse.org/t/uris-to-the-origin-of-a-thread-that-has-since-been-merged-should-503-to-the-merged-comment/342417?u=rokejulianlockhart (or https://meta.discourse.org/ap/object/bc8f042ccca5ef56734c5f2460aa45cc) [1] into mastodon.social/search, it 404s: [2] [3]

If this isn’t Discourse’s fault, I’ll take this to Mastodon. However, most other AP platforms that I’ve tried (that I’ve expected to work) have worked.


  1. https://meta.discourse.org/t/uris-to-the-origin-of-a-thread-that-has-since-been-merged-should-503-to-the-merged-comment/342417?u=rokejulianlockhart ↩︎

  2. search?q=https%3A%2F%2Fmeta.discourse.org%2Fap%2Fobject%2Fbc8f042ccca5ef56734c5f2460aa45cc ↩︎

  3. search?q=https%3A%2F%2Fmeta.discourse.org%2Ft%2Furis-to-the-origin-of-a-thread-that-has-since-been-merged-should-503-to-the-merged-comment%2F342417%3Fu%3Drokejulianlockhart ↩︎

1 Like

I’m missing this as well. Without this, it is hard or impossible to interact with federated posts unless they are in your timeline already.

@roke_julian_lockhart, just curious, have you tried with URLs of WordPress instances using the WP ActivityPub plugin?

1 Like

What the heck has occurred here? I have never written like the undermentioned:

RokeJulianLockhart:

Discuss this on our forum.

...and someone's taken a sledgehammer to my markup.

1 Like

Oh! They’re federated now! I didn’t post that comment here. [1] They’re merely rather broken in their federation:

  1. The formatting isn’t conserved.

  2. I am able to like my own posts.

    It’s a separate user account, since it’s registered on another domain.

@icaria36, no. Do you know of any?


  1. socialhub.activitypub.rocks/t/5123/3 ↩︎

I believe this is a WordPress site, and I just tested with a recent article, and I can find the URL on Mastodon indeed: Nature Holds Awe, Man – NHAM Mixtape 11 – NHAM

@icaria36, I don’t think so. Discourse has native AP integration.

@roke_julian_lockhart To your point when you created this topic, meanwhile, https://meta.discourse.org/t/why-are-supposedly-activitypub-federated-discourse-threads-inaccessible-via-external-ap-clients/356997 cannot be found on Mastodon.

1 Like

@icaria36, it’s probably a fault of Mastodon’s, then, since Discourse federates it:

1 Like

github.com/mastodon/mastodon/discussions/34600#discussioncomment-13031935 states:

The Discourse AP plugin makes ActivityPub objects available when you click the green ActivityPub logo and click the “Note” button to copy the URL: https://meta.discourse.org/ap/object/5874fad7df806caa1fe34c382c1d2991

Discourse AP needs to make the url link back to the id in some way, preferably via a redirect on requests with the correct Accept content negotiation header.

Consequently, I’ll tentatively set this as a Contribute > Bug. (I can’t. Too old.)

But the URLs provided by the “Notes” icon don’t throw any results when pasted on i.e. mastodon.social/search.

Problem not solved.

1 Like

@icaria36, please comment that on the GitHub Discussion. Having someone else challenge the response lends some more credibility than having me be the liason.

1 Like

Looks like that:

https://github.com/mastodon/mastodon/issues/34632

1 Like

Well, no, it seems that it might be a Discourse bug after all: Posts from Discourse do not resolve via the Search API · Issue #34632 · mastodon/mastodon · GitHub

Investigating a bit more, Mastodon requests the resource with the following Accept header:

Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams", text/html;q=0.1

Querying discourse with this results in the HTTP 400 response.

Omitting the text/html;q=0.1 returns an ActivityStreams object. So this seems to be a bug with Discourse, which seems to return a 400 anytime text/html is part of the accepted types…

1 Like

@roke_julian_lockhart or a mod can you remove the “Solution”, please? And move this topic to Contribute > Bug (or create a new bug report) based on Mastodon’s assessment on Posts from Discourse do not resolve via the Search API · Issue #34632 · mastodon/mastodon · GitHub.

2 Likes

I’m not sure this is a bug in Discourse. I’ve responded on the issue on Mastodon. Cross posting here for convenience:

The reason we return a 400 in that scenario is that the ActivityPub spec seems to require it.

POST requests (eg. to the inbox) MUST be made with a Content-Type of application/ld+json; profile=“ActivityStreams 2.0 Terms” and GET requests (see also 3.2 Retrieving objects) with an Accept header of application/ld+json; profile=“ActivityStreams 2.0 Terms”

@ClearlyClaire Is there a need to add text/html;q=0.1 to the Accept header?

2 Likes

This will be resolved soon. See further:

https://github.com/mastodon/mastodon/issues/34632#issuecomment-2892159150

https://github.com/discourse/discourse-activity-pub/pull/219

3 Likes