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

KeyError: 'http://schema.org/item' #96

Open
tisdall opened this issue May 31, 2019 · 0 comments
Open

KeyError: 'http://schema.org/item' #96

tisdall opened this issue May 31, 2019 · 0 comments

Comments

@tisdall
Copy link

tisdall commented May 31, 2019

The exception goes away if I either remove the @id or the url in the ListItem. I'm new to this so maybe the format is wrong, but it seems like pyld should raise a JsonLdError if that were the case and not a KeyError.

I'm running pyld 1.0.5 on Python 2.7.15 .

from pyld import jsonld
x = jsonld.frame(
  {
    "@context": "http://schema.org",
    "@graph": [
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "item": {
              "@id": "https://example.com/",
              "@type": "WebPage",
              "url": "https://example.com/"
            }
          }
        ]
      }
    ]
  },
  {}
)

Output:

Traceback (most recent call last):
  File "<console>", line 15, in <module>
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 201, in frame
    return JsonLdProcessor().frame(input_, frame, options)
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 982, in frame
    framed = self._frame(expanded, expanded_frame, options)
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 2545, in _frame
    state, sorted(state['subjects'].keys()), frame, framed, None)
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 3516, in _match_frame
    state, [o['@id']], subframe, output, prop)
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 3516, in _match_frame
    state, [o['@id']], subframe, output, prop)
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 3434, in _match_frame
    self._remove_embed(state, id_)
  File "/usr/local/lib/python2.7/site-packages/pyld/jsonld.py", line 3784, in _remove_embed
    use_array = _is_array(embed['parent'][property])
KeyError: u'http://schema.org/item'
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