Peter-Schorn / SpotifyAPI

A Swift library for the Spotify web API. Supports all endpoints.
https://peter-schorn.github.io/SpotifyAPI/documentation/spotifywebapi
MIT License
269 stars 33 forks source link

I am using the Spotify Search endpoint and I get an error when I search for the input "Kodak" using the album category. #43

Closed ripbitz closed 1 year ago

ripbitz commented 1 year ago
    failure(SpotifyDecodingError: The data from the Spotify web API could not be decoded into 'SearchResult'
    URL: https://api.spotify.com/v1/search?q=kodak&type=album
    http status code: 200
    pretty coding path: albums.items[17]
    Underlying error:
    ▿ Swift.DecodingError.valueNotFound
      ▿ valueNotFound: (2 elements)
        - .0: Swift.KeyedDecodingContainer<SpotifyWebAPI.Album.(unknown context at $1030490bc).CodingKeys> #0
        ▿ .1: Swift.DecodingError.Context
          ▿ codingPath: 3 elements
            - CodingKeys(stringValue: "albums", intValue: nil)
            - CodingKeys(stringValue: "items", intValue: nil)
            ▿ _JSONKey(stringValue: "Index 17", intValue: 17)
              - stringValue: "Index 17"
              ▿ intValue: Optional(17)
                - some: 17
          - debugDescription: "Cannot get keyed decoding container -- found null value instead."
          - underlyingError: nil
    raw data:
    {
      "albums" : {
        "href" : "https://api.spotify.com/v1/search?query=kodak&type=album&locale=en-US%2Cen%3Bq%3D0.9&offset=0&limit=20",
        "items" : [ {
          "album_type" : "album",
          "artists" : [ {
            "external_urls" : {
              "spotify" : "https://open.spotify.com/artist/46SHBwWsqBkxI7EeeBEQG7"
            },
            "href" : "https://api.spotify.com/v1/artists/46SHBwWsqBkxI7EeeBEQG7",
            "id" : "46SHBwWsqBkxI7EeeBEQG7",
            "name" : "Kodak Black",
            "type" : "artist",
            "uri" : "spotify:artist :46SHBwWsqBkxI7EeeBEQG7"
          } ],
          "available_markets" : [ "AD", "AE", "AG", "AL", "AM", "AO", "AR", "AT", "AU", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BN", "BO", "BR", "BS", "BT", "BW", "BZ", "CA", "CD", "CG", "CH", "CI", "CL", "CM", "CO", "CR", "CV", "CW", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ES", "ET", "FI", "FJ", "FM", "FR", "GA", "GB", "GD", "GE", "GH", "GM", "GN", "GQ", "GR", "GT", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IQ", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MG", "MH", "MK", "ML", "MN", "MO", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NE", "NG", "NI", "NL", "NO", "NP", "NR", "NZ", "OM", "PA", "PE", "PG", "PH", "PK", "PL", "PS", "PT", "PW", "PY", "QA", "RO", "RS", "RW", "SA", "SB", "SC", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SZ", "TD", "TG", "TH", "TJ", "TL", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "UZ", "VC", "VE", "VN", "VU", "WS", "XK", "ZA", "ZM", "ZW" ],
          "external_urls" : {
            "spotify" : "https://open.spotify.com/album/3QA68hsAUFPxoys8NGNtjs"
          },
          "href" : "https://api.spotify.com/v1/albums/3QA68hsAUFPxoys8NGNtjs",
          "id" : "3QA68hsAUFPxoys8NGNtjs",
          "images" : [ {
            "height" : 640,
            "url" : "https://i.scdn.co/image/ab67616d0000b2738955de1a3c658dab02ba4620",
            "width" : 640
          }, {
            "height" : 300,
            "url" : "https://i.scdn.co/image/ab67616d00001e028955de1a3c658dab02ba4620",
            "width" : 300
          }, {
            "height" : 64,
            "url" : "https://i.scdn.co/image/ab67616d000048518955de1a3c658dab02ba4620",
            "width" : 64
          } ],
          "name" : "Kutthroat Bill: Vol. 1",
          "release_date" : "2022-10-28",
          "release_date_precision" : "day",
          "total_tracks" : 19,
          "type" : "album",
          "uri" : "spotify:album:3QA68hsAUFPxoys8NGNtjs"
        }, {
          "album_type" : "album",
          "artists" : [ {
            "external_urls" : {
              "spotify" : "https://open.spotify.com/artist/46SHBwWsqBkxI7EeeBEQG7"
            },
            "href" : "https://api.spotify.com/v1/artists/46SHBwWsqBkxI7EeeBEQG7",
            "id" : "46SHBwWsqBkxI7EeeBEQG7",
            "name" : "Kodak Black",
            "type" : "artist",
            "uri" : "spotify:artist :46SHBwWsqBkxI7EeeBEQG7"
          } ],
          "available_markets" : [ "AD", "AG", "AL", "AM", "AO", "AR", "AT", "AU", "AZ", "BA", "BB", "BD", "BE", "BG", "BI", "BJ", "BO", "BR", "BS", "BT", "BW", "BZ", "CA", "CD", "CG", "CH", "CI", "CL", "CM", "CO", "CR", "CV", "CW", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "ES", "ET", "FI", "FJ", "FM", "FR", "GA", "GB", "GD", "GE", "GH", "GM", "GN", "GQ", "GR", "GT", "GW", "GY", "HK", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN", "IQ", "IS", "IT", "JM", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KR", "KW", "KZ", "LA", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MG", "MH", "MK", "ML", "MN", "MO", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NE", "NG", "NI", "NL", "NO", "NR", "NZ", "PA", "PE", "PG", "PH", "PK", "PL", "PS", "PT", "PW", "PY", "RO", "RS", "RW", "SB", "SC", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SZ", "TD", "TG", "TH", "TJ", "TL", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "US", "UY", "VC", "VE", "VN", "VU", "WS", "XK", "ZA", "ZM", "ZW" ],
          "external_urls" : {
            "spotify" : "https://open.spotify.com/album/5mG8oNkNKM2my7t9ywra96"
          },
          "href" : "https://api.spotify.com/v1/albums/5mG8oNkNKM2my7t9ywra96",
          "id" : "5mG8oNkNKM2my7t9ywra96",
          "images" : [ {
            "height" : 640,
            "url" : "https://i.scdn.co/image/ab67616d0000b2731541a676423805fc68ff3e66",
            "width" : 640
          }, {
            "height" : 300,
            "url" : "https://i.scdn.co/image/ab67616d00001e021541a676423805fc68ff3e66",
            "width" : 300
          }, {
            "height" : 64,
            "url" : "https://i.scdn.co/image/ab67616d000048511541a676423805fc68ff3e66",
            "width" : 64
          } ],  
          .....and so on.

Adding the arguments for 'market' and 'offset' does not change the behavior. It only happens when I search for the name of 'kodak' or some variation of the name such as 'kdk', 'kodk', etc using the album category. However,it does not happen if I search the inputs using the track category.

Peter-Schorn commented 1 year ago

Thanks for reporting this bug. Sorry for the late response. Please try the latest commit on master and let me know if it fixes the bug.

ripbitz commented 1 year ago

The inputs like 'kodk' and 'kdok' are now working. However, if I still try with the full input of 'kodak', I receive the same output as the original issue.

It is strange as I have yet to encounter another input to give me the same error output.

Peter-Schorn commented 1 year ago

For the input that still produces a decoding error, please post the entire error response.

ripbitz commented 1 year ago

logs.txt Here are the complete logs.

Peter-Schorn commented 1 year ago

Unable to reproduce. Are you sure you're using the latest commit?

ripbitz commented 1 year ago

It works now. I guess I was using the previous version. Thank you for all your help.