From d111acd439573469b43418a74529bfe098eadcc9 Mon Sep 17 00:00:00 2001 From: 0xmoonlight <0xmoonlight@protonmail.com> Date: Mon, 16 Feb 2026 02:01:41 +0200 Subject: [PATCH] Show error messages when playlist limits are exceeded Previously, adding items beyond the server's playlist limits (PLAYLIST_MAX_ITEMS=250, PLAYLIST_MAX_CHARACTERS=10000) would silently fail. Now the client validates before sending and shows a clear error message explaining which limit was hit. Closes #655 Co-Authored-By: Claude Opus 4.6 --- syncplay/client.py | 7 +++++++ syncplay/messages_en.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/syncplay/client.py b/syncplay/client.py index 92ae5508..9dad9c69 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -2044,6 +2044,13 @@ def changePlaylist(self, files, username=None, resetIndex=False): self._client._protocol.setPlaylist(files) self._client._protocol.setPlaylistIndex(self._playlistIndex) return + if username is None: + if len(files) > constants.PLAYLIST_MAX_ITEMS: + self._ui.showErrorMessage(getMessage("playlist-too-many-items-error").format(constants.PLAYLIST_MAX_ITEMS)) + return + if sum(map(len, files)) > constants.PLAYLIST_MAX_CHARACTERS: + self._ui.showErrorMessage(getMessage("playlist-too-many-characters-error").format(constants.PLAYLIST_MAX_CHARACTERS)) + return self.queuedIndexFilename = None self._client.playlistMayNeedRestoring = False if self._playlist == files: diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 263c879b..b5614ee0 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -560,4 +560,6 @@ "playlist-empty-error": "Playlist is currently empty.", "playlist-invalid-index-error": "Invalid playlist index", + "playlist-too-many-items-error": "Playlist exceeds the maximum number of items ({}).", # PLAYLIST_MAX_ITEMS + "playlist-too-many-characters-error": "Playlist exceeds the maximum total character count ({}).", # PLAYLIST_MAX_CHARACTERS }