Issue description:
I have a Navidrome server that I synced my playlists with. I reinstalled the server and attempted to sync the playlists that were stored on the app to the server. This caused a panic on the server because the playlists did not exist there yet and the app did not recreate them.
opened 08:12PM - 22 Feb 24 UTC
bug
triage
### Version
0.51.1
### Current Behavior
I have a Navidrome install and … attempted to sync my playlist to the server. Server failed with a Go panic. Also fails if the playlist already exists on the server. Fails on a fresh install as well as an existing one.
### Steps To Reproduce
Not sure.
### Environment
```markdown
- OS: Android
- Client: Symfonium
```
### How Navidrome is installed?
Binary (from downloads page)
### Configuration
```toml
MusicFolder = "/music"
EnableSharing = true
Spotify.ID = "xxx"
Spotify.Secret = "xxx"
LastFM.Enabled = true
LastFM.ApiKey = "xxx"
LastFM.Secret = "xxx"
```
### Relevant log output
```shell
ERRO[0463] data not found id=a31a6c66-ad8c-4916-915f-fe89fbae905a requestId=navidrome/EGMpupM3A1-000049 username=USER
WARN[0463] API: Failed response endpoint=/rest/getPlaylist.view error=70 message="Directory not found" requestId=navidrome/EGMpupM3A1-000049 username=USER
ERRO[0463] Error getting playlist's tracks - THIS SHOULD NOT HAPPEN! error="data not found" playlistId=a31a6c66-ad8c-4916-915f-fe89fbae905a requestId=navidrome/EGMpupM3A1-000050 username=USER
panic: runtime error: invalid memory address or nil pointer dereference
-> github.com/navidrome/navidrome/core.(*playlists).Update.func1
-> /github/workspace/core/playlists.go:238
github.com/navidrome/navidrome/persistence.(*SQLStore).WithTx.func1
/github/workspace/persistence/persistence.go:116
github.com/pocketbase/dbx.(*DB).Transactional
/go/pkg/mod/github.com/pocketbase/[email protected] /db.go:220
github.com/navidrome/navidrome/persistence.(*SQLStore).WithTx
/github/workspace/persistence/persistence.go:114
github.com/navidrome/navidrome/core.(*playlists).Update
/github/workspace/core/playlists.go:228
github.com/navidrome/navidrome/server/subsonic.(*Router).UpdatePlaylist
/github/workspace/server/subsonic/playlists.go:148
github.com/navidrome/navidrome/server/subsonic.(*Router).routes.func5.h.func6
/github/workspace/server/subsonic/api.go:206
github.com/navidrome/navidrome/server/subsonic.hr.func1
/github/workspace/server/subsonic/api.go:213
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server/subsonic.(*Router).routes.func5.getPlayer.func1.1
/github/workspace/server/subsonic/middlewares.go:174
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5.(*ChainHandler).ServeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected] /chain.go:31
github.com/go-chi/chi/v5.(*Mux).routeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected] /mux.go:443
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server/subsonic.(*Router).routes.authenticate.func17.1
/github/workspace/server/subsonic/middlewares.go:107
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server/subsonic.checkRequiredParameters.func1
/github/workspace/server/subsonic/middlewares.go:67
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server/subsonic.postFormToQueryParams.func1
/github/workspace/server/subsonic/middlewares.go:41
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5.(*Mux).ServeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected] /mux.go:73
github.com/go-chi/chi/v5.(*Mux).Mount.func1
/go/pkg/mod/github.com/go-chi/chi/[email protected] /mux.go:315
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.requestLogger.func1
/github/workspace/server/middlewares.go:33
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.jwtVerifier.jwtVerifier.Verify.func1.func2
/go/pkg/mod/github.com/go-chi/jwtauth/[email protected] /jwtauth.go:78
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.authHeaderMapper.func1
/github/workspace/server/auth.go:181
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.loggerInjector.func1
/github/workspace/server/middlewares.go:64
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5/middleware.(*Compressor).Handler-fm.(*Compressor).Handler.func1
/go/pkg/mod/github.com/go-chi/chi/[email protected] /middleware/compress.go:209
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.clientUniqueIDMiddleware.func1
/github/workspace/server/middlewares.go:157
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.serverAddressMiddleware.func1
/github/workspace/server/middlewares.go:185
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.(*Server).initRoutes.robotsTXT.func4.1
/github/workspace/server/middlewares.go:75
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.(*Server).initRoutes.Heartbeat.func3.1
/go/pkg/mod/github.com/go-chi/chi/[email protected] /middleware/heartbeat.go:21
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5/middleware.Recoverer.func1
/go/pkg/mod/github.com/go-chi/chi/[email protected] /middleware/recoverer.go:45
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/navidrome/navidrome/server.realIPMiddleware.RealIP.func1
/go/pkg/mod/github.com/go-chi/chi/[email protected] /middleware/realip.go:36
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5/middleware.RequestID.func1
/go/pkg/mod/github.com/go-chi/chi/[email protected] /middleware/request_id.go:76
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/cors.(*Cors).Handler-fm.(*Cors).Handler.func1
/go/pkg/mod/github.com/go-chi/[email protected] /cors.go:228
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/unrolled/secure.(*Secure).Handler-fm.(*Secure).Handler.func1
/go/pkg/mod/github.com/unrolled/[email protected] /secure.go:198
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5.(*ChainHandler).ServeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected] /chain.go:31
github.com/go-chi/chi/v5.(*Mux).routeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected] /mux.go:443
net/http.HandlerFunc.ServeHTTP
/usr/local/go/src/net/http/server.go:2136
github.com/go-chi/chi/v5.(*Mux).ServeHTTP
/go/pkg/mod/github.com/go-chi/chi/[email protected] /mux.go:90
net/http.serverHandler.ServeHTTP
/usr/local/go/src/net/http/server.go:2938
net/http.(*conn).serve
/usr/local/go/src/net/http/server.go:2009
created by net/http.(*Server).Serve in goroutine 13
/usr/local/go/src/net/http/server.go:3086
```
**nginx log:**
```
xxx.xxx.xxx.xxx - - [22/Feb/2024:13:26:21 -0700] "GET /rest/getPlaylist.view?id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx&u=USER&t=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&s=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&v=1.13.0&c=Symfonium&f=json HTTP/1.1" 200 198 "-" "Symfonium/8.0.0a (Linux;Android 9)"
xxx.xxx.xxx.xxx - - [22/Feb/2024:13:26:21 -0700] "GET /rest/updatePlaylist.view?playlistid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx&name=Soundtracks&songIdToAdd=78015b4f9c721df0b4e33bb16a3b932a&songIdToAdd=da08b18759193594bbd59ee0bb571a6e&songIdToAdd=6f2b949d020ee9047594d5689206a61c&songIdToAdd=13bec94e965882c02ea01bda2ba0c5f9&songIdToAdd=f67cf96bb1c23e183e4643f135a12069&songIdToAdd=ef8a632a80498e757404d75fde360277&songIdToAdd=e0b1479df48f051bb5b0d91201bd3a7e&songIdToAdd=1a21128a7a9a6ea281cad1dc35ddd7ed&songIdToAdd=e9a71751b3ce06b71ae49d6f2733abbb&songIdToAdd=75a31f95c2cc3a20d9ccf45d66945a65&songIdToAdd=e890512e286ad6f5dc23aefaefd5470a&songIdToAdd=40653d953252729d16fd1275f57602fb&songIdToAdd=d63c7b014c7ac9948876353fe5722ea3&songIdToAdd=0258baa9615146d9913de2086dae4937&songIdToAdd=c15a72fcdf8cd8a8b8745ceff12cd52a&songIdToAdd=a3ab8502f3fed328e263ec193429fe38&songIdToAdd=03c9e8384fa14c525f373ff332f265cc&songIdToAdd=c0aba156228dc50f2cc10cb45357b1e7&songIdToAdd=33da6740ab32dc464bab9066c74853f0&songIdToAdd=c8307814a52968183131628207ed9659&songIdToAdd=98189dd958e2de2eaa2d530e8f4d7ed3&songIdToAdd=e55b362351ac2566e5b3a6fce87270d8&songIdToAdd=13e4801187f4cd2ec310d1a33ca82475&songIdToAdd=9172612898643c96a3efbd770e9654b2&songIdToAdd=e0c921995d25a89084dce4eff68daccb&songIdToAdd=27b4139a3c1d0c44fc8d288f421b4e3e&songIdToAdd=8bbfd15b7d1a126e1cf3fc45431162d4&songIdToAdd=8625277bd4eeb1d034a21f0b7c7c486b&songIdToAdd=a77b92cc9c3083a689867f2619e42c07&songIdToAdd=0b292e63d92b9546ed711674079e94e2&songIdToAdd=7267f33ddc9813d8fe466c8c7a5d2550&songIdToAdd=12ff6f467661224e691f97b05b60b63b&songIdToAdd=7d6d1153c4d9fd96bfdeb8e7dd0bdcef&songIdToAdd=9ba0584c661bc4cb61673c58062d2cac&songIdToAdd=88c1e672a4320830f2a6ff8063b22d9d&songIdToAdd=1212c439c39bb2a519e8898ea9708413&songIdToAdd=577b7e9b431c7b7bc9f60742c8da0540&songIdToAdd=ab231bd422d45f7aa95b580b8092bfa2&songIdToAdd=44f99d014379c7bdbe7a16f7e5363015&songIdToAdd=9c860b2350fd26ae7aa01bc91aed1dcd&songIdToAdd=7c0a9b0596c24331576f9045d592fdf1&songIdToAdd=7490f77a025e38fdbb388d8af2edb113&songIdToAdd=75cc9571d0d3e8cfe939e861fee53758&songIdToAdd=520adf1d9776ecebebec9b6d28989360&songIdToAdd=4b6de98456cc5865465734bbb28a61e5&songIdToAdd=decdd0ea4fbda13ed637d244f3e968a0&songIdToAdd=d3c52c895e294cd58d79b64c076b1a5b&songIdToAdd=c918ec0e5b43ec621cb1719e9aa44255&songIdToAdd=5221eef0e3584c7aee787ec561d9d4a3&songIdToAdd=acbe6578fd82581718c09bafb414ea77&u=USER&t=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&s=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&v=1.13.0&c=Symfonium&f=json HTTP/1.1" 500 0 "-" "Symfonium/8.0.0a (Linux;Android 9)"
```
I assume the issue is because the app is trying to sync to the server without first checking if the playlists exist there yet. It would be cool to have the app create the playlist on the server if it doesn’t exist yet.
Logs:
Upload description: shows error
Additional information:
Workaround is to create a new playlist and then copy the contents of the old playlist over.
Reproduction steps:
Install Navidrome
Create a playlist in Symfonium and sync it to the server.
Delete the Navidrome database and restart the server.
Attempt to sync the playlist from the app to the server.
Media provider:
Subsonic
Screenshots:
Tolriq
February 29, 2024, 5:55pm
2
Well this is normal and expected (That it fails, the crash should be fixed by Navidrome).
If you successfully sync from / to Navidrome the playlist have a server ID to ensure integrity. If the ID no more exists on the server then your server have an issue and the sync should fail. There’s no proper automatic recovery here.
Select all the songs in the playlists and create a new playlist to upload if you forget to save your Navidrome database.
Okay, great. Just wanted to make sure it wasn’t a bug. Thanks for your hard work.