Peter-Schorn/SpotifyAPI

Decoder error when release year is `0000`

Closed this issue · 3 comments

Bit of a strange one, but I noticed that a SpotifyDecodingError happens when an album has a release date of 0000, like this album: https://open.spotify.com/album/5QDyhsfWwW2783pyaDjV6J

This is clearly an error on Spotify's side, but I was wondering if there's a way to make SpotifyAPI more resilient to this happening in some way. The issue at the moment is that it means the entire page of results is lost, not just this one track

The only workaround for this problem is to set the Album.releaseDate (and other properties decoded from date-strings) to nil when the date-string cannot be parsed from the JSON data. I think this is an acceptable solution here because if Spotify returns a date-string with an invalid format, there's nothing the client can do about it. Expect a new version with this change shortly.

Also, as an aside, the year 0 does not exist in the Gregorian calendar; it goes from 1 B.C. to 1 A.D. This is why "0000" is always invalid when parsing date-strings using the Unicode Technical Standard #35, although not for ISO 8601, in which 0 represents 1 B.C.

I have pushed a new version with this change: 067861d.

Thanks so much! It's unfortunate that Spotify has this bug, but at least there's a workaround.