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 expansion with context containing empty list #159

Open
georgkrause opened this issue Jun 30, 2021 · 1 comment
Open

Invalid expansion with context containing empty list #159

georgkrause opened this issue Jun 30, 2021 · 1 comment

Comments

@georgkrause
Copy link

I am currently trying to upgrade pyld to version 2.0.x. But sadly some of our test cases fail and I think thats due to an Bug in pyld.

The problem seems to be an empty {} as part of the context. Lets have a little example:

payload = {
    "id": "https://noop/federation/actors/demo",
    "outbox": "https://noop/federation/actors/demo/outbox",
    "inbox": "https://noop/federation/actors/demo/inbox",
    "preferredUsername": "demo",
    "type": "Person",
    "name": "demo",
    "followers": "https://noop/federation/actors/demo/followers",
    "following": "https://noop/federation/actors/demo/following",
    "manuallyApprovesFollowers": False,
    "@context": [
        "https://www.w3.org/ns/activitystreams",
        "https://w3id.org/security/v1",
        {}
    ],
    "endpoints": {"sharedInbox": "https://noop/federation/shared/inbox"},
}

print(jsonld.expand(payload))

The result of this is a simple []. I verified the same code with the JSON-LD Playground and there the result is, as I would expect:

[
  {
    "https://www.w3.org/ns/activitystreams#endpoints": [
      {
        "https://www.w3.org/ns/activitystreams#sharedInbox": [
          {
            "@id": "https://noop/federation/shared/inbox"
          }
        ]
      }
    ],
    "https://www.w3.org/ns/activitystreams#followers": [
      {
        "@id": "https://noop/federation/actors/demo/followers"
      }
    ],
    "https://www.w3.org/ns/activitystreams#following": [
      {
        "@id": "https://noop/federation/actors/demo/following"
      }
    ],
    "@id": "https://noop/federation/actors/demo",
    "http://www.w3.org/ns/ldp#inbox": [
      {
        "@id": "https://noop/federation/actors/demo/inbox"
      }
    ],
    "_:manuallyApprovesFollowers": [
      {
        "@value": "False"
      }
    ],
    "https://www.w3.org/ns/activitystreams#name": [
      {
        "@value": "demo"
      }
    ],
    "https://www.w3.org/ns/activitystreams#outbox": [
      {
        "@id": "https://noop/federation/actors/demo/outbox"
      }
    ],
    "https://www.w3.org/ns/activitystreams#preferredUsername": [
      {
        "@value": "demo"
      }
    ],
    "@type": [
      "https://www.w3.org/ns/activitystreams#Person"
    ]
  }
]

So I tested the same expansion with pyld but without the empty list as part of the context, and the result is as expected:

[
  {
    "https://www.w3.org/ns/activitystreams#endpoints": [
      {
        "https://www.w3.org/ns/activitystreams#sharedInbox": [
          {
            "@id": "https://noop/federation/shared/inbox"
          }
        ]
      }
    ],
    "https://www.w3.org/ns/activitystreams#followers": [
      {
        "@id": "https://noop/federation/actors/demo/followers"
      }
    ],
    "https://www.w3.org/ns/activitystreams#following": [
      {
        "@id": "https://noop/federation/actors/demo/following"
      }
    ],
    "@id": "https://noop/federation/actors/demo",
    "http://www.w3.org/ns/ldp#inbox": [
      {
        "@id": "https://noop/federation/actors/demo/inbox"
      }
    ],
    "_:manuallyApprovesFollowers": [
      {
        "@value": false
      }
    ],
    "https://www.w3.org/ns/activitystreams#name": [
      {
        "@value": "demo"
      }
    ],
    "https://www.w3.org/ns/activitystreams#outbox": [
      {
        "@id": "https://noop/federation/actors/demo/outbox"
      }
    ],
    "https://www.w3.org/ns/activitystreams#preferredUsername": [
      {
        "@value": "demo"
      }
    ],
    "@type": [
      "https://www.w3.org/ns/activitystreams#Person"
    ]
  }
]
@georgkrause
Copy link
Author

The example shows the issue with an dict, not as I said with an empty list. But the problem occurs with both: An empty list and an empty dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant