Skip to content

panic: invalid uri: when prefetching a track #97

@aykevl

Description

@aykevl

In some circumstances (not yet sure when this happens but it seems to have something to do with playing whole albums), next.Uri is an empty string here:

nextId := librespot.SpotifyIdFromUri(next.Uri)

This leads to a crash:

go-librespot/ids.go

Lines 110 to 114 in b95e6ac

func SpotifyIdFromUri(uri string) SpotifyId {
id, err := SpotifyIdFromUriSafe(uri)
if err != nil {
panic(err)
}

The next object in this case looks like this:

&connectstate.ContextTrack{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(nil)}, sizeCache:0, unknownFields:[]uint8(nil), Uri:"", Uid:"a1e0611f0a14df708f14", Gid:[]uint8{0x7, 0x7d, 0x48, 0x4f, 0x2c, 0x99, 0x4d, 0x24, 0x93, 0xcf, 0x57, 0x1, 0xfd, 0x71, 0xd7, 0x31}, Metadata:map[string]string{"context_uri":"spotify:album:0tiOfqFu4d3UJ2r1LsoG3Z", "entity_uri":"spotify:album:0tiOfqFu4d3UJ2r1LsoG3Z"}}

If you look into it, there's an album ID ("entity_uri":"spotify:album:0tiOfqFu4d3UJ2r1LsoG3Z"), and something that looks like a track ID (Uid:"a1e0611f0a14df708f14"). So it looks like there's enough information to prefetch this track, but I'm not entirely sure how to implement it.
(Interestingly this only happens while prefetching, perhaps the code that pulls the track ID when actually playing a track takes care of this case? In which case it would make sense to generalize that code and use it in both places).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions