python-kit icon indicating copy to clipboard operation
python-kit copied to clipboard

Exception thrown when Media Link field contains a link to an mp4 (and possibly other non-image links)

Open anthonycats opened this issue 6 years ago • 1 comments

Here's the traceback when trying to fetch the document in question:

Traceback (most recent call last):
  File "test.py", line 49, in <module>
    response = form.submit()
  File "/usr/local/lib/python3.7/site-packages/prismic/api.py", line 272, in submit
    request_handler=self.request_handler
  File "/usr/local/lib/python3.7/site-packages/prismic/api.py", line 350, in __init__
    self.documents = [Document(d) for d in data.get("results")]
  File "/usr/local/lib/python3.7/site-packages/prismic/api.py", line 350, in <listcomp>
    self.documents = [Document(d) for d in data.get("results")]
  File "/usr/local/lib/python3.7/site-packages/prismic/api.py", line 394, in __init__
    self.fragments[f_key] = Fragment.from_json(fragment_value)
  File "/usr/local/lib/python3.7/site-packages/prismic/fragments.py", line 52, in from_json
    return f_type(data.get("value"))
  File "/usr/local/lib/python3.7/site-packages/prismic/fragments.py", line 289, in __init__
    self.name = self.image.get("name")
AttributeError: 'NoneType' object has no attribute 'get'

Here's what the data in the field looks like:

"qwerty": {
  "type": "Link.file",
   "value": {
    "file": {
      "name": "1514560395-definitivehairydairycow.mp4",
      "kind": "document",
      "url": "https://redacted.prismic.io/redacted%2F94ff171b-ec65-4867-a0fb-1fa97f2b1bda_1514560395-definitivehairydairycow.mp4",
      "size": "129914"
    }
  }
},

anthonycats avatar Apr 30 '19 15:04 anthonycats

@anthonycats Did you find any workaround to this? Even I'm struggling with the same.

ankit-patnaik avatar May 05 '20 20:05 ankit-patnaik