Fix truncated results for chunked (partial) command responses#183
Open
OzGav wants to merge 1 commit into
Open
Conversation
The server streams large API command results (such as playlist tracks for big playlists) as multiple SuccessResultMessages: every 500 items is sent with partial=True, followed by a final message with partial=False. The client ignored the `partial` flag and resolved the command on the first message, so callers only ever received the first 500 items. Accumulate partial result chunks (keyed by message_id) in both the listening and non-listening code paths, and only return once the final (non-partial) message arrives. Also fix get_playlist_tracks: it accepted a `page` argument that the server endpoint does not use (the server returns the whole listing in one call, streamed in chunks). Replace it with the `force_refresh` argument that the server actually supports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes music-assistant/support#4371
The server streams large API command results (such as playlist tracks for big playlists) as multiple
SuccessResultMessages: every 500 items is sent withpartial=True, followed by a final message withpartial=False. The client ignored thepartialflag and resolved the command on the first message, so callers only ever received the first 500 items.Accumulate partial result chunks (keyed by
message_id) in both the listening and non-listening code paths, and only return once the final (non-partial) message arrives.Also fix
get_playlist_tracks: it accepted apageargument that the server endpoint does not use (the server returns the whole listing in one call, streamed in chunks). Replace it with theforce_refreshargument that the server actually supports.Verified against the real client code with a server-accurate mock (501/1000/2347-track playlists all return in full; confirmed the pre-fix code truncated at 500).