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

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…