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

dataclass_wizard.errors.UnknownJSONKey: A JSON key is missing from the dataclass schema for class Video. unknown key: 'tags' #75

Open
KaneDM opened this issue Dec 22, 2023 · 4 comments

Comments

@KaneDM
Copy link

KaneDM commented Dec 22, 2023

  • Wistia API Helper version: Latest
  • Python version: 3.11
  • Operating System: Win 10

Description

Crashed while running my Wistia upload/HTML dump script, which has worked previously. Code here:
https://github.com/KaneDM/wistia-upload-embed/blob/main/tvid.py

The video was uploaded successfully, and the thumbnail was successfully created and assigned, but something went wrong during the thumbnail assignment.

What I Did

Crashed on line 83 of my script, where I call WistiaApi.update_video(vidid, thumbnail_media_id=tn.hashed_id).

Traceback (most recent call last):
  File "D:\Python\tvid.py", line 83, in <module>
    WistiaApi.update_video(vidid, thumbnail_media_id=tn.hashed_id)
  File "C:\Python311\Lib\site-packages\wystia\api_data.py", line 347, in update_video
    return cls.update_media(
           ^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\wystia\api_data.py", line 396, in update_media
    return model_cls.from_dict(r.json())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\dataclass_wizard\loaders.py", line 536, in fromdict
    return load(d)
           ^^^^^^^
  File "C:\Python311\Lib\site-packages\dataclass_wizard\loaders.py", line 611, in cls_fromdict
    field_name = lookup_field_for_json_key(o, json_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\dataclass_wizard\loaders.py", line 705, in lookup_field_for_json_key
    raise e from None
dataclass_wizard.errors.UnknownJSONKey: A JSON key is missing from the dataclass schema for class `Video`.
  unknown key: 'tags'
  dataclass fields: ['hashed_id', 'id', 'name', 'type', 'created', 'updated', 'duration', 'status', 'description', 'progress', 'thumbnail', 'project', 'embed_code', 'assets', 'section', 'archived', 'has_audio_description', 'captions_enabled', 'overlay_text', 'caption_duration', 'num_captions', 'ad_disabled']
  input JSON object: {"id": 113495448, "name": "Blep", "type": "Video", "archived": false, "created": "2023-12-22T19:27:51+00:00", "updated": "2023-12-22T19:27:52+00:00", "duration": 1583.04, "hashed_id": "d8wh65z917", "description": "", "progress": 0.14285714285714285, "status": "queued", "thumbnail": {"url": "https://embed-ssl.wistia.com/deliveries/955004dbcdfd7aef4f136c28c495f0df.jpg?image_crop_resized=200x120&video_still_time=791", "width": 200, "height": 120}, "tags": []}

Appears to be the same kind of problem as issue #59.

@rnag
Copy link
Owner

rnag commented Jan 31, 2024

Hi @KaneDM , thanks for opening this issue. I have to create a scheduled job that runs to make API requests, and then create an issue or attempt to fix code if there are any missing fields that are encountered.. this is on my bucket list for now.

In the meantime, can you try setting env variable RAISE_ON_UNKNOWN_KEY to false or 0, as shown in below file. Let me know if that helps for now.

$ export RAISE_ON_UNKNOWN_KEY=0
$ <call script>

https://github.com/rnag/wystia/blob/main/wystia/constants.py#L26

@KaneDM
Copy link
Author

KaneDM commented Feb 1, 2024

Hi @rnag,

Appreciate the update. Thankfully, for my particular use case, it wasn't affecting any of the actual operations of the script (it even does what it's supposed to do on that line, just crashes after). I wrapped that part of the script in a try/except to catch the error and it's currently running fine.

If you want me to try your proposed solution for testing purposes, let me know and I can do that.

@rnag
Copy link
Owner

rnag commented Feb 8, 2024

Yes, please try the proposed solution and let me know if it works.

@KaneDM
Copy link
Author

KaneDM commented Feb 8, 2024

Not confident enough in setting env variables to know if I did that right, but if I go to line 26 of the file you linked and change True to False , the error does go away.

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

2 participants