dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
946 stars 46 forks source link

App crash with third-party WAF server in front of Navidrome #495

Closed tofuliang closed 1 month ago

tofuliang commented 1 month ago

Seems navidrome is not respond correctly.

OS Version : x86_64 14.6.1 (23G93)

❯ Supersonic.app/Contents/MacOS/supersonic
2024/10/15 23:51:26 Starting supersonic...
2024/10/15 23:51:26 Using config dir: /Users/runner/Library/Application Support/supersonic
2024/10/15 23:51:26 Using cache dir: /Users/runner/Library/Caches/supersonic
2024/10/15 23:51:27 failed to load theme file "": open /Users/runner/Library/Application Support/supersonic/themes: no such file or directory
2024-10-15 23:51:27.810 supersonic[12301:291804] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:.
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Home" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Back" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Forward" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Reload" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Menu" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Mute" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Repeat" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Show play queue" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:28 Fyne error:  Translation failure
2024/10/15 23:51:28   Cause: message "Now Playing" not found in language "zh"
2024/10/15 23:51:28   At: /Users/runner/go/pkg/mod/github.com/dweymouth/fyne/v2@v2.3.0-rc1.0.20240819150801-f6d6d2ad82de/lang/lang.go:72
2024/10/15 23:51:29 failed to load saved play queue: saved play queue was from a different server
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1007a9cf8]

goroutine 101 [running]:
github.com/supersonic-app/go-subsonic/subsonic.(*Client).GetPlaylists(...)
    /Users/runner/go/pkg/mod/github.com/supersonic-app/go-subsonic@v0.0.0-20240807031555-2cb1ccd78f85/subsonic/playlist.go:19
github.com/dweymouth/supersonic/backend/mediaprovider/subsonic.(*subsonicMediaProvider).GetPlaylists(0xc0002fae70)
    /Users/runner/work/supersonic/supersonic/backend/mediaprovider/subsonic/subsonicmediaprovider.go:208 +0x118
github.com/dweymouth/supersonic/ui/browsing.(*PlaylistsPage).load(0xc00329b590, 0x0)
    /Users/runner/work/supersonic/supersonic/ui/browsing/playlistspage.go:112 +0x35
created by github.com/dweymouth/supersonic/ui/browsing.newPlaylistsPage in goroutine 170
    /Users/runner/work/supersonic/supersonic/ui/browsing/playlistspage.go:97 +0x748
tofuliang commented 1 month ago

After some investigation, Supersonic received a 403 response from Navidrome. Perhaps changing the User Agent from Go-http-client to something else might help?

dweymouth commented 1 month ago

I use Navidrome myself and have not run into this issue so I don't think the user-agent is the issue. Does this only happen with the playlists page? Or do you also get crashes when loading the albums, artists, etc pages? In any case, we don't want to be crashing even if a 403 is returned so I will look into fixing the crash from your stack trace

tofuliang commented 1 month ago

I figured it out using Charles proxy. I'm using a third-party Navidrome service that is protected by a WAF. The WAF detects the Go User Agent and directly responds with a 403 error.

image
tofuliang commented 1 month ago

I tried changing the User Agent to something else on my local machine, and it no longer crashes.

image
dweymouth commented 1 month ago

Would changing the User-Agent to "Supersonic" work? Trying to evaluate options for a hardcoded user agent

tofuliang commented 1 month ago

Yes, "Supersonic" works !

dweymouth commented 1 month ago

@tofuliang I pushed a fix, if you can build from source it'd be great if you can test it and let me know if it resolves it on your end

dweymouth commented 1 month ago

Oh, I forgot you can download the Github Actions build to test the fix as well: https://github.com/dweymouth/supersonic/actions/runs/11388277777

tofuliang commented 1 month ago

@tofuliang I pushed a fix, if you can build from source it'd be great if you can test it and let me know if it resolves it on your end

I built it from source and can confirm that it fixed the issue. Thanks a lot!