Code Monkey home page Code Monkey logo

Comments (8)

Kuwertzel avatar Kuwertzel commented on July 30, 2024 1

Sounds good to me! I'll probably work with the library in the next few days, so I'll see if anything is broken :D
Thank you and Happy Holidays!

from tekore.

felix-hilden avatar felix-hilden commented on July 30, 2024

Hi and thank you for submitting the issue! We've made some related changes recently, so please let me know if upgrading Tekore helps. But if it doesn't I'll see what this is about! And to be fair, I saw something similar in our daily test run, so it might be a recent change. The validation error is misleading because the type is a union (of track and episode) so Pydantic just spits out everything even though it might be really close to one of them.

from tekore.

Kuwertzel avatar Kuwertzel commented on July 30, 2024

Hi, I discovered the bug on the current version 5.2.1.
I also just tested on v5.2.0, v5.1.0 and v5.0.0. All of them run into the same error.

Thank you for your help! This is such an awesome library 👏

from tekore.

felix-hilden avatar felix-hilden commented on July 30, 2024

Thank you 🙏 one thing would help a lot still: could you upgrade Pydantic too? In our tests I see that Show publisher has an object inside rather than the string advertised in the docs and the OpenAPI spec, and is_playable is missing despite being "required". Our error messages are a bit different but I'm curious if you could be seeing something similar.

from tekore.

Kuwertzel avatar Kuwertzel commented on July 30, 2024

Yep, my pydantic version was quite outdated. I upgraded to pydantic 2.5.2 and pydantic-core 2.14.5.

I get a more verbose traceback now. The is_playable is marked as missing and the FullPlaylistEpisode.show.publisher indeed appears to be an object, judging from the traceback.

tracks.items.0.track.FullPlaylistEpisode.is_playable
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
tracks.items.0.track.FullPlaylistEpisode.show.publisher
  Input should be a valid string [type=string_type, input_value={'name': 'detektor.fm – Das Podcast-Radio'}, input_type=dict]

To be fair though, pydantic still complains about seemingly every field.

In case it helps; the full traceback is appended, with only errors for the available_markets items abbreviated:

Traceback (most recent call last):
  File "C:\Users\user\source\repos\spotify-enhanced\mre.py", line 9, in <module>
    playlist_containing_podcasts = spotify.playlist('6qODgO8aCg7y35VKI9wfBI')  # Test playlist
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\source\repos\spotify-enhanced\venv\Lib\site-packages\tekore\_client\api\playlist\view.py", line 43, in wrapper
    return post_func(json)
           ^^^^^^^^^^^^^^^
  File "C:\Users\user\source\repos\spotify-enhanced\venv\Lib\site-packages\tekore\_client\process.py", line 29, in post_func
    return type_(**json) if json is not None else None
           ^^^^^^^^^^^^^
  File "C:\Users\user\source\repos\spotify-enhanced\venv\Lib\site-packages\tekore\_model\serialise.py", line 48, in __init__
    super().__init__(**data)
  File "C:\Users\user\source\repos\spotify-enhanced\venv\Lib\site-packages\pydantic\main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 193 validation errors for FullPlaylist
tracks.items.0.track.FullPlaylistTrack.artists
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.disc_number
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.is_local
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.preview_url
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.track_number
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.album
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.external_ids
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.popularity
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistTrack.episode
  Input should be False [type=literal_error, input_value=True, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.5/v/literal_error
tracks.items.0.track.FullPlaylistTrack.track
  Input should be True [type=literal_error, input_value=False, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.5/v/literal_error
tracks.items.0.track.FullPlaylistEpisode.is_playable
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.FullPlaylistEpisode.show.publisher
  Input should be a valid string [type=string_type, input_value={'name': 'detektor.fm – Das Podcast-Radio'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/string_type
tracks.items.0.track.LocalPlaylistTrack.id
  Input should be None [type=none_required, input_value='6zxFogoXXfgP1hevPFo8hf', input_type=str]
    For further information visit https://errors.pydantic.dev/2.5/v/none_required
tracks.items.0.track.LocalPlaylistTrack.href
  Input should be None [type=none_required, input_value='https://api.spotify.com/.../6zxFogoXXfgP1hevPFo8hf', input_type=str]
    For further information visit https://errors.pydantic.dev/2.5/v/none_required
tracks.items.0.track.LocalPlaylistTrack.album
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.artists
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.available_markets.0
  Input should be None [type=none_required, input_value='AD', input_type=str]
    For further information visit https://errors.pydantic.dev/2.5/v/none_required

[...]

tracks.items.0.track.LocalPlaylistTrack.available_markets.168
  Input should be None [type=none_required, input_value='ZW', input_type=str]
    For further information visit https://errors.pydantic.dev/2.5/v/none_required
tracks.items.0.track.LocalPlaylistTrack.disc_number
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.external_ids
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.is_local
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.popularity
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.preview_url
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.track_number
  Field required [type=missing, input_value={'explicit': False, 'audi...6zxFogoXXfgP1hevPFo8hf'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
tracks.items.0.track.LocalPlaylistTrack.episode
  Input should be False [type=literal_error, input_value=True, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.5/v/literal_error
tracks.items.0.track.LocalPlaylistTrack.track
  Input should be True [type=literal_error, input_value=False, input_type=bool]
    For further information visit https://errors.pydantic.dev/2.5/v/literal_error

from tekore.

felix-hilden avatar felix-hilden commented on July 30, 2024

Thank you! The episode model has also been updated to have restrictions and to deprecate language, so I'll update them at the same time.

from tekore.

felix-hilden avatar felix-hilden commented on July 30, 2024

And apparently markets in the playlist episode version :P and also local track duration_ms is an object. Maybe they're having a bad week over there 😅

from tekore.

felix-hilden avatar felix-hilden commented on July 30, 2024

I cannot successfully run the test suite locally either due to unrelated errors. So I'll just release this along with other minor stuff. Merry Christmas!

from tekore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.