Bad content negotiation (Accept header) during WebFinger discovery
Hi all! First off, thanks for building and maintaining Pleroma. It's great!
I build and run a service (https://fed.brid.gy/) that's trying to federate with Pleroma, and one part it's gotten stuck on is inbound WebFinger discovery. When Pleroma fetches /.well-known/host-meta
and WebFinger queries, it sends the HTTP header Accept: application/xrd+xml,application/jrd+json
, signalling that it can handle both XRD and JRD responses. However, if my service returns JSON JRD with Content-Type: application/jrd+json
, Pleroma attempts to parse it as XML and fails. Example log snippet:
Mar 10 13:54:17 MatrixRock pleroma[7585]: 13:54:17.462 request_id=Fmr_mvne5kH7O3MADlJi [debug] Processing with Pleroma.Web.ActivityPub.ActivityPubController.inbox/2
Mar 10 13:54:17 MatrixRock pleroma[7585]: Parameters: %{"@context" => "https://www.w3.org/ns/activitystreams", "nickname" => "jk", "object" => %{"@context" => "https://www.w3.org/ns/activitystreams", "type" => "Create", ...}
Mar 10 13:54:17 MatrixRock pleroma[7585]: Pipelines: [:activitypub]
Mar 10 13:54:21 MatrixRock pleroma[7585]: 13:54:21.128 request_id=Fmr_mvne5kH7O3MADlJi [debug] Couldn't parse XML: "{\n \"subject\": \"acct:jk.nipponalba.scot@jk.nipponalba.scot\",\n \"aliases\": [\n \"https://jk.nipponalba.scot/\",\n \"https://social.nipponalba.scot/jk\",\n \"https://px.nipponalba.scot/jk\"\n ],\n \"magic_keys\": [\n {\n \"value\": \"data:application/magic-public-key,RSA.3Wq8cM8ZzWydoZ3ljmB5GCaMJKcooELcZVHdFY4EkB8MVPZFqn26xwVQA8k7XKov-HQM0Hd1JwiNUzzZ5-Cz2WPT1qIlnd2ZdfxHyxcTuy1PRku33Ei0JMo-STYUpTdyPED7nWW8m64EQ1WWKKA3tQ_uduSixqgtmo6yFTog0U0=.AQAB\"\n }\n ],\n \"links\": [\n {\n \"rel\": \"http://webfinger.net/rel/profile-page\",\n \"type\": \"text/html\",\n \"href\": \"https://jk.nipponalba.scot/\"\n },\n {\n \"rel\": \"http://webfinger.net/rel/profile-page\",\n \"type\": \"text/html\",\n \"href\": \"https://social.nipponalba.scot/jk\"\n },\n {\n \"rel\": \"http://webfinger.net/rel/profile-page\",\n \"type\": \"text/html\",\n \"href\": \"https://px.nipponalba.scot/jk\"\n },\n {\n \"rel\": \"http://webfinger.net/rel/avatar\",\n \"href\": {\n \"value\": \"https://jk.nipponalba.scot/images/profile.jpg\",\n \"alt\": \"profile picture\"\n }\n },\n {\n \"rel\": \"canonical_uri\",\n \"type\": \"text/html\",\n \"href\": \"https://jk.nipponalba.scot/\"\n },\n {\n \"rel\": \"self\",\n \"type\": \"application/activity+json\",\n \"href\": \"https://fed.brid.gy/jk.nipponalba.scot\"\n },\n {\n \"rel\": \"inbox\",\n \"type\": \"application/activity+json\",\n \"href\": \"https://fed.brid.gy/jk.nipponalba.scot/inbox\"\n },\n {\n \"rel\": \"http://schemas.google.com/g/2010#updates-from\",\n \"type\": \"application/atom+xml\",\n \"href\": \"http://jk.nipponalba.scot/atom.xml\"\n },\n {\n \"rel\": \"hub\",\n \"href\": \"https://bridgy-fed.superfeedr.com/\"\n },\n {\n \"rel\": \"magic-public-key\",\n \"href\": \"data:application/magic-public-key,RSA.3Wq8cM8ZzWydoZ3ljmB5GCaMJKcooELcZVHdFY4EkB8MVPZFqn26xwVQA8k7XKov-HQM0Hd1JwiNUzzZ5-Cz2WPT1qIlnd2ZdfxHyxcTuy1PRku33Ei0JMo-STYUpTdyPED7nWW8m64EQ1WWKKA3tQ_uduSixqgtmo6yFTog0U0=.AQAB\"\n },\n {\n \"rel\": \"salmon\",\n \"href\": \"https://fed.brid.gy/jk.nipponalba.scot/salmon\"\n }\n ]\n}"
The simplest fix would be to change your Accept header during WebFinger discovery to just Accept: application/xrd+xml
. Alternatively, you could also start handling JSON JRD.
More background in https://github.com/snarfed/bridgy-fed/issues/12. Thanks in advance!