Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing ActivityPub "3.2 Retrieving objects" server response #9982

Closed
senooken opened this issue Feb 18, 2023 · 8 comments
Closed

Missing ActivityPub "3.2 Retrieving objects" server response #9982

senooken opened this issue Feb 18, 2023 · 8 comments
Labels
🌌Federation The Federation/ActivityPub feature packages/backend Server side specific issue/PR

Comments

@senooken
Copy link

概要

MisskeyがActivityPubの 3.2 Retrieving objects でMUSTとなっている応答を返さないため、返すようにしてほしいです。

手順

具体的には、以下のGETで応答を返してほしいです。

curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' https://misskey.io/notes/9a85p8ho8t

Misskey.io以外の https://msk.ilnk.info/notes/9bb179i1ek でも404で応答がないことを確認しました。

現状は上記のヘッダーがあると100%、404が返ってきています。

期待

Mastodon/WildeBeest/GNU socialなど他の実装だと、投稿パーマリンクに対する上記のGETで以下のような応答を返します。

curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' https://mstdn.jp/@senooken/109801670562174553
{"@context":["https://www.w3.org/ns/activitystreams",{"ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","sensitive":"as:sensitive","toot":"http://joinmastodon.org/ns#","votersCount":"toot:votersCount"}],"id":"https://mstdn.jp/users/senooken/statuses/109801670562174553","type":"Note","summary":"cw","inReplyTo":"https://mstdn.jp/users/senooken/statuses/109801668127149887","published":"2023-02-03T16:08:49Z","url":"https://mstdn.jp/@senooken/109801670562174553","attributedTo":"https://mstdn.jp/users/senooken","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mstdn.jp/users/senooken/followers"],"sensitive":true,"atomUri":"https://mstdn.jp/users/senooken/statuses/109801670562174553","inReplyToAtomUri":"https://mstdn.jp/users/senooken/statuses/109801668127149887","conversation":"tag:mstdn.jp,2022-12-30:objectId=336738822:objectType=Conversation","content":"\u003cp\u003e間違えた。\u003cbr /\u003e空行なし。\u003c/p\u003e\u003cp\u003e空行あり。\u003c/p\u003e","contentMap":{"ja":"\u003cp\u003e間違えた。\u003cbr /\u003e空行なし。\u003c/p\u003e\u003cp\u003e空行あり。\u003c/p\u003e"},"attachment":[],"tag":[],"replies":{"id":"https://mstdn.jp/users/senooken/statuses/109801670562174553/replies","type":"Collection","first":{"type":"CollectionPage","next":"https://mstdn.jp/users/senooken/statuses/109801670562174553/replies?only_other_accounts=true\u0026page=true","partOf":"https://mstdn.jp/users/senooken/statuses/109801670562174553/replies","items":[]}}}

Misskeyでも上記のような応答を返してほしいです。

仕様

ActivityPubの該当仕様 3.2 Retrieving objects は以下のとおりです。

3.2 Retrieving objects

The HTTP GET method may be dereferenced against an object's id property to retrieve the activity. Servers MAY use HTTP content negotiation as defined in [RFC7231] to select the type of data to return in response to a request, but MUST present the ActivityStreams object representation in response to application/ld+json; profile="https://www.w3.org/ns/activitystreams", and SHOULD also present the ActivityStreams representation in response to application/activity+json as well. The client MUST specify an Accept header with the application/ld+json; profile="https://www.w3.org/ns/activitystreams" media type in order to retrieve the activity.

クライアント側がGETするのは [may] なので任意ですが、サーバー側の応答は [MUST present the ActivityStreams object representation in response to application/ld+json; profile="https://www.w3.org/ns/activitystreams"] にあるとおり、必須 (MUST) です。

GNU social (GS) では、POST /inbox.jsonでMisskeyからlikeなどの要請があった場合に、https://notabug.org/diogo/gnu-social/src/master/plugins/ActivityPub/ActivityPubPlugin.php#L114 あたりのコードで、DBに該当投稿があるか検索して、なければ上記仕様に基づき該当投稿をGETしにいきます。

Misskeyが応答を返さないため、ここの処理が失敗して500エラーになっていました。

MisskeyとGNU socialとの通信でGS側で500がでて、再リクエストのためにMisskey側の通信負荷が高まっているとの複数の報告を受け確認したところ判明しました。

GS側で以下のようにガードをすれば500はでませんが、GET時の404は出たままになります。

            if (is_array($object) && Activitypub_notice::validate_note($object)) {

既存Misskey用に上記ガードはいれますが、Misskey側でActivityPubの必須機能を実装していないのがまずいと思いますので、対応いただきたく思います (発端)。

@senooken senooken added the ⚠️bug? This might be a bug label Feb 18, 2023
@acid-chicken acid-chicken added 🐛Bug Unexpected behavior packages/backend Server side specific issue/PR 🌌Federation The Federation/ActivityPub feature and removed ⚠️bug? This might be a bug labels Feb 18, 2023
@acid-chicken
Copy link
Member

missing というよりは @fastify/accepts に乗り換えてから Accept がちゃんとパースされなくなったかもしれない

const LD_JSON = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"; charset=utf-8';

@rinsuki
Copy link
Contributor

rinsuki commented Feb 18, 2023

動くところでは動いている謎

$ curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' -D /dev/stderr -s https://misskey.noellabo.jp/notes/92glmd94h1?nocache="$(date +%Y%m%d%H%M%S)" | jq
HTTP/2 200
date: Sat, 18 Feb 2023 10:56:22 GMT
content-type: application/ld+json; profile="https://www.w3.org/ns/activitystreams"; charset=utf-8
content-length: 1222
vary: Accept
strict-transport-security: max-age=2592000; includeSubDomains; preload
access-control-allow-headers: Accept
access-control-allow-methods: GET, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: Vary
cache-control: public, max-age=180
x-cached: MISS
cf-cache-status: DYNAMIC
(snip)
x-content-type-options: nosniff
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
      "sensitive": "as:sensitive",
      "Hashtag": "as:Hashtag",
      "quoteUrl": "as:quoteUrl",
      "toot": "http://joinmastodon.org/ns#",
      "Emoji": "toot:Emoji",
      "featured": "toot:featured",
      "discoverable": "toot:discoverable",
      "schema": "http://schema.org#",
      "PropertyValue": "schema:PropertyValue",
      "value": "schema:value",
      "misskey": "https://misskey-hub.net/ns#",
      "_misskey_content": "misskey:_misskey_content",
      "_misskey_quote": "misskey:_misskey_quote",
      "_misskey_reaction": "misskey:_misskey_reaction",
      "_misskey_votes": "misskey:_misskey_votes",
      "_misskey_talk": "misskey:_misskey_talk",
      "isCat": "misskey:isCat",
      "vcard": "http://www.w3.org/2006/vcard/ns#"
    }
  ],
  "id": "https://misskey.noellabo.jp/notes/92glmd94h1",
  "type": "Note",
  "attributedTo": "https://misskey.noellabo.jp/users/7wix547ltx",
  "content": "<p><span>a</span></p>",
  "_misskey_content": "a",
  "source": {
    "content": "a",
    "mediaType": "text/x.misskeymarkdown"
  },
  "published": "2022-07-08T22:33:35.896Z",
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "cc": [
    "https://misskey.noellabo.jp/users/7wix547ltx/followers"
  ],
  "inReplyTo": null,
  "attachment": [],
  "sensitive": false,
  "tag": []
}

@rinsuki
Copy link
Contributor

rinsuki commented Feb 18, 2023

Misskey.io以外の https://msk.ilnk.info/notes/9bb179i1ek でも404で応答がないことを確認しました。

これは単純に非公開投稿だからっぽい (application/activity+json でもだめ)

@Ry0taK
Copy link
Contributor

Ry0taK commented Feb 18, 2023

ここで localOnly: false が指定されているため、ローカルのみ で投稿された投稿が取得できていない雰囲気がありますね (https://misskey.io/notes/9a85p8ho8tローカルのみで投稿されています)

@rinsuki
Copy link
Contributor

rinsuki commented Feb 18, 2023

別に misskey.io でも動く時は動く

$ curl -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' -D /dev/stderr -s https://misskey.io/notes/9bdetsrvod | jq
HTTP/2 200
date: Sat, 18 Feb 2023 11:01:54 GMT
content-type: application/ld+json; profile="https://www.w3.org/ns/activitystreams"; charset=utf-8
content-length: 1630
vary: Accept
strict-transport-security: max-age=2592000; includeSubDomains; preload
access-control-allow-headers: Accept
access-control-allow-methods: GET, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: Vary
cache-control: public, max-age=180
cf-cache-status: DYNAMIC
(snip)
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
(snip)

@rinsuki
Copy link
Contributor

rinsuki commented Feb 18, 2023

それはそうとして

GNU social (GS) では、POST /inbox.jsonでMisskeyからlikeなどの要請があった場合に、https://notabug.org/diogo/gnu-social/src/master/plugins/ActivityPub/ActivityPubPlugin.php#L114 あたりのコードで、DBに該当投稿があるか検索して、なければ上記仕様に基づき該当投稿をGETしにいきます。
Misskeyが応答を返さないため、ここの処理が失敗して500エラーになっていました。

Likeがinboxに来た後投稿が消えて404になるということは全然ありうるのでちゃんと GNU Social 側でもハンドリングすべきっぽい

@rinsuki
Copy link
Contributor

rinsuki commented Feb 18, 2023

ひょっとして local only な投稿への Like が外部に漏れていたりする? そんなことはなさそう

@senooken
Copy link
Author

すみません。最初の再現手順の投稿は公開範囲がlocalになっていました。元投稿が一般公開だとちゃんと応答がありました。

@rinsuki rinsuki closed this as not planned Won't fix, can't repro, duplicate, stale Feb 18, 2023
@acid-chicken acid-chicken added 🚫Invalid and removed 🐛Bug Unexpected behavior labels Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌌Federation The Federation/ActivityPub feature packages/backend Server side specific issue/PR
Projects
None yet
Development

No branches or pull requests

4 participants