activitypub-express icon indicating copy to clipboard operation
activitypub-express copied to clipboard

Akkoma's posts cannot be received due to "Error processing request JSON-LD"

Open ShadowJonathan opened this issue 2 years ago • 2 comments

After some additional debugging logging, we figured out why a.gup.pe was not accepting posts from our instance, it replies with "Error processing request JSON-LD", which is defined here: https://github.com/immers-space/activitypub-express/blob/37b711906b4fc545184d5ad6e3d38110aa314a80/net/validators.js#L167

We're using Akkoma 3.11


The JSON we were trying to send to the inbox was the following;

Long JSON
{
    "@context": [
        "https://www.w3.org/ns/activitystreams",
        "https://cooltrans.men/schemas/litepub-0.1.jsonld",
        {
            "@language": "und"
        }
    ],
    "actor": "https://cooltrans.men/users/jo",
    "cc": [
        "https://www.w3.org/ns/activitystreams#Public"
    ],
    "context": "https://cooltrans.men/contexts/0443005c-aaf5-4557-b156-39087a5035d2",
    "directMessage": false,
    "id": "https://cooltrans.men/activities/1399b1f9-b48d-4790-b9ed-db6114011bff",
    "object": {
        "actor": "https://cooltrans.men/users/jo",
        "attachment": [],
        "attributedTo": "https://cooltrans.men/users/jo",
        "cc": [
            "https://www.w3.org/ns/activitystreams#Public"
        ],
        "content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"AfRIZEdbPmhJwgNVuC\" href=\"https://a.gup.pe/u/test\" rel=\"ugc\">@<span>test</span></a></span> A test post",
        "contentMap": {
            "en": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"AfRIZEdbPmhJwgNVuC\" href=\"https://a.gup.pe/u/test\" rel=\"ugc\">@<span>test</span></a></span> A test post"
        },
        "context": "https://cooltrans.men/contexts/0443005c-aaf5-4557-b156-39087a5035d2",
        "conversation": "https://cooltrans.men/contexts/0443005c-aaf5-4557-b156-39087a5035d2",
        "id": "https://cooltrans.men/objects/2702435d-83fa-4b49-a18f-be4636ee3e8c",
        "published": "2024-03-02T13:11:10.574761Z",
        "sensitive": null,
        "source": {
            "content": "@[email protected] A test post",
            "mediaType": "text/plain"
        },
        "summary": "",
        "tag": [
            {
                "href": "https://a.gup.pe/u/test",
                "name": "@[email protected]",
                "type": "Mention"
            }
        ],
        "to": [
            "https://cooltrans.men/users/jo/followers",
            "https://a.gup.pe/u/test"
        ],
        "type": "Note"
    },
    "published": "2024-03-02T13:11:10.574683Z",
    "to": [
        "https://cooltrans.men/users/jo/followers",
        "https://a.gup.pe/u/test"
    ],
    "type": "Create"
}

ShadowJonathan avatar Mar 02 '24 13:03 ShadowJonathan

I've figured out whats happening.

With a normal akkoma install, it'll fail with the following error;

Uncaught:
jsonld.InvalidUrl: Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.
    at ContextResolver._fetchContext (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/ContextResolver.js:186:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ContextResolver._resolveRemoteContext (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/ContextResolver.js:117:34)
    at async ContextResolver.resolve (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/ContextResolver.js:50:22)
    at async api.process (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/context.js:87:20)
    at async api.expand (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/expand.js:214:17)
    at async jsonld.expand (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/jsonld.js:321:18)
    at async jsonld.compact (/Users/j0j0/dev/activitypub-express/node_modules/jsonld/lib/jsonld.js:171:16) {
  details: {
    code: 'invalid remote context',
    url: 'https://cooltrans.men/schemas/litepub-0.1.jsonld'
  }
}

However, fetching that content manually reveals that the content-type is not properly set, it says application/octet-stream.

Strongarming the reverse proxy to set it to application/json makes it work again.

ShadowJonathan avatar Mar 02 '24 14:03 ShadowJonathan

This was tracked on akkoma's side with https://akkoma.dev/AkkomaGang/akkoma/issues/716, now closed and fixed with 3.12.0

ShadowJonathan avatar Mar 31 '24 18:03 ShadowJonathan