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

Invalid JSON-LD syntax; @context must be an object. #296

Closed
wiwie opened this issue Apr 11, 2020 · 13 comments
Closed

Invalid JSON-LD syntax; @context must be an object. #296

wiwie opened this issue Apr 11, 2020 · 13 comments
Labels
Milestone

Comments

@wiwie
Copy link

@wiwie wiwie commented Apr 11, 2020

When following my writefreely user chris@blog.cwiwie.org from friendica chris@friendica.cwiwie.org I get the following error response upon writing new posts / updating posts in writefreely:

2020/04/10 22:51:59 Response: JsonLdException: [jsonld.SyntaxError]: Invalid JSON-LD syntax; @context must be an object.

From the json-ld spec it also seems that the context is supposed to be an object or a link to a jsonld file: https://www.w3.org/TR/2020/CR-json-ld11-20200316/#the-context

@wiwie
Copy link
Author

@wiwie wiwie commented Apr 11, 2020

This is the JSON ld in question:

{
  "@context": [
    "https://www.w3.org/ns/activitystreams"
  ],
  "type": "OrderedCollectionPage",
  "id": "https://blog.cwiwie.org/api/collections/chris/outbox?page=1",
  "totalItems": 3,
  "partOf": "https://blog.cwiwie.org/api/collections/chris/outbox",
  "next": "https://blog.cwiwie.org/api/collections/chris/outbox?page=2",
  "orderedItems": [
    {
      "@context": [
        "https://www.w3.org/ns/activitystreams",
        {}
      ],
      "type": "Create",
      "id": "https://blog.cwiwie.org/api/posts/5pfxj55e0l",
      "actor": "https://blog.cwiwie.org/api/collections/chris",
      "published": "2020-04-10T21:25:51+02:00",
      "object": {
        "type": "Article",
        "id": "https://blog.cwiwie.org/api/posts/5pfxj55e0l",
        "published": "2020-04-10T21:25:51+02:00",
        "inReplyTo": null,
        "url": "https://blog.cwiwie.org/asdasd-asdsdd-sdds",
        "attributedTo": "https://blog.cwiwie.org/api/collections/chris",
        "to": [
          "https://www.w3.org/ns/activitystreams#Public"
        ],
        "cc": [
          "https://blog.cwiwie.org/api/collections/chris/followers"
        ],
        "name": "asdasd asdsdD SDDS",
        "content": "<p><img src=\"https://wolke.cwiwie.org/s/syTTsZob3J66HW4/preview\" alt=\"Test Image\"></p>\n",
        "contentMap": {
          "en": "<p><img src=\"https://wolke.cwiwie.org/s/syTTsZob3J66HW4/preview\" alt=\"Test Image\"></p>\n"
        },
        "tag": []
      }
    },
    {
      "@context": [
        "https://www.w3.org/ns/activitystreams",
        {}
      ],
      "type": "Create",
      "id": "https://blog.cwiwie.org/api/posts/eiftt4yilf",
      "actor": "https://blog.cwiwie.org/api/collections/chris",
      "published": "2020-04-10T19:54:40+02:00",
      "object": {
        "type": "Article",
        "id": "https://blog.cwiwie.org/api/posts/eiftt4yilf",
        "published": "2020-04-10T19:54:40+02:00",
        "inReplyTo": null,
        "url": "https://blog.cwiwie.org/the-whole-screen-is-covered",
        "attributedTo": "https://blog.cwiwie.org/api/collections/chris",
        "to": [
          "https://www.w3.org/ns/activitystreams#Public"
        ],
        "cc": [
          "https://blog.cwiwie.org/api/collections/chris/followers"
        ],
        "name": "the whole screen is covered",
        "content": "<p>with the left side</p>\n",
        "contentMap": {
          "de": "<p>with the left side</p>\n"
        },
        "tag": []
      }
    },
    {
      "@context": [
        "https://www.w3.org/ns/activitystreams",
        {}
      ],
      "type": "Create",
      "id": "https://blog.cwiwie.org/api/posts/jt8lfz6mko",
      "actor": "https://blog.cwiwie.org/api/collections/chris",
      "published": "2020-04-10T19:27:58+02:00",
      "object": {
        "type": "Article",
        "id": "https://blog.cwiwie.org/api/posts/jt8lfz6mko",
        "published": "2020-04-10T19:27:58+02:00",
        "inReplyTo": null,
        "url": "https://blog.cwiwie.org/test-post",
        "attributedTo": "https://blog.cwiwie.org/api/collections/chris",
        "to": [
          "https://www.w3.org/ns/activitystreams#Public"
        ],
        "cc": [
          "https://blog.cwiwie.org/api/collections/chris/followers"
        ],
        "name": "Test Post",
        "content": "<p>bla test.</p>\n\n<p>_ Blubb _</p>\n\n<p><img src=\"https://wolke.cwiwie.org/s/syTTsZob3J66HW4/preview\" alt=\"test image\"></p>\n",
        "contentMap": {
          "de": "<p>bla test.</p>\n\n<p>_ Blubb _</p>\n\n<p><img src=\"https://wolke.cwiwie.org/s/syTTsZob3J66HW4/preview\" alt=\"test image\"></p>\n"
        },
        "tag": []
      }
    }
  ]
}
@thebaer
Copy link
Member

@thebaer thebaer commented Apr 11, 2020

Hey, thanks for the report. I thought this was a bug at first, but I'm not sure based on the information here. Further down on the page you referenced:

Contexts can either be directly embedded into the document (an embedded context) or be referenced using a URL.

And you can confirm other AP platforms like Mastodon produce similar JSON-LD.

I'm sure we could clean up the extra @contexts in the JSON you provided, and maybe change from an array to a string at the top-level of the document (since we aren't extending the definition), but otherwise might be something on Friendica's end.

@annando
Copy link

@annando annando commented Apr 13, 2020

Friendica is compacting the JSON-LD input before processing. This compacting is done via a JSON-LD library (and it only works when the JSON-LD itself is valid). This also means that we are more picky like other projects, but this compacting makes the parsing easier for us.

I still have to have a deeper look at this issue. But when I found out that it isn't an issue on our side, it would be great if you could apply some changes on some development machine and that I could check it from our side, just to make sure that everything is okay.

@annando
Copy link

@annando annando commented Apr 13, 2020

I just had a look at the outboxes of other projects. Mastodon for example isn't providing a @context for each entry in the outbox - and I think that this is the correct behaviour.

@thebaer
Copy link
Member

@thebaer thebaer commented Apr 13, 2020

Yep, just removed those fields on outboxes on our test instance. If you need to create an account for testing there, here's an invite link.

Let me know if that fixes the issue, or if we need to make any other changes.

@annando
Copy link

@annando annando commented Apr 13, 2020

The outbox looks fine now. And I just signed up and got the most beautiful error message I ever got:

Server error 😵

Please contact the human authors of this software and remind them of their many shortcomings.

Be gentle, though. They are fragile mortal beings.

Also, unlike the AI that will soon replace them, you will need to include an error log from the server in your report. (Utterly primitive, we know.)

– Pencil 🤖

@thebaer
Copy link
Member

@thebaer thebaer commented Apr 15, 2020

Haha, whoops! Needed to mess with the database. That should be fixed now if you want to try again.

@thebaer
Copy link
Member

@thebaer thebaer commented Apr 20, 2020

@annando Just to confirm, did that outbox change fix everything on Friendica's end?

@annando
Copy link

@annando annando commented Apr 20, 2020

I guess so, but I will perform some tests with the test account.

@thebaer
Copy link
Member

@thebaer thebaer commented Apr 21, 2020

Sounds good. Just merged the fix in #299, so if everything looks good on your end we can close this.

@wiwie
Copy link
Author

@wiwie wiwie commented Apr 23, 2020

I can confirm that this fixes it for me. Should we close this issue or do you want to perform some further testing @annando?

@annando
Copy link

@annando annando commented Apr 23, 2020

@wiwie when it works for you, it's great. I want to do several communication tests.

@thebaer
Copy link
Member

@thebaer thebaer commented Apr 24, 2020

I'll close this for now, since we seemed to have fixed this particular issue. But if anything comes up in your testing @annando please feel free to open a new issue, or continue the discussion here!

@thebaer thebaer closed this Apr 24, 2020
@thebaer thebaer added this to the 0.12 milestone Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.