From 5afaa493c1dbadd7c22e76f4b2a91f542d6f9702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 28 May 2026 18:02:14 +0300 Subject: [PATCH 1/2] Remove app metadata from scrobble payloads The Trakt scrobble API only requires progress and the media object. Sending undocumented app_version/app_date fields with null values causes 400 responses from the API. Fixes #100 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- trakt/sync.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/trakt/sync.py b/trakt/sync.py index 30e9f9d..27382bd 100644 --- a/trakt/sync.py +++ b/trakt/sync.py @@ -607,8 +607,7 @@ def _post(self, uri): :param uri: The uri to post to """ - payload = dict(progress=self.progress, app_version=self.version, - date=self.date) + payload = dict(progress=self.progress) payload.update(self.media.to_json_singular()) response = yield uri, payload yield response From beef1b0bc2062e17bd964474423c00a218cb4af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 28 May 2026 18:02:15 +0300 Subject: [PATCH 2/2] Add regression test for scrobble payload fields Verify that scrobble payloads do not include undocumented app_version, app_date, or date fields that can cause 400 responses from the Trakt API. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tests/test_scrobble.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_scrobble.py b/tests/test_scrobble.py index ab84dbd..cfaf89b 100644 --- a/tests/test_scrobble.py +++ b/tests/test_scrobble.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +from unittest.mock import patch + from trakt.movies import Movie from trakt.sync import Scrobbler @@ -22,3 +24,28 @@ def test_scrobbler_context_manager(): with Scrobbler(guardians, 0.0, '1.0.0', '2015-02-01') as scrob: for i in range(10): scrob.update(i*10) + + +def test_scrobbler_payload_excludes_app_metadata(): + """scrobble payload must not include undocumented app_version/date fields""" + import trakt.core + guardians = Movie('Guardians of the Galaxy', year=2014) + scrobbler = Scrobbler(guardians, 42.0, '1.0.0', '2015-02-01') + + with patch.object(trakt.core.api(), 'post', return_value=None) as mock_post: + scrobbler.start() + + print("call_args:", mock_post.call_args) + print("args:", getattr(mock_post.call_args, "args", None)) + print("tuple:", tuple(mock_post.call_args)) + + args, kwargs = mock_post.call_args + assert not kwargs + assert len(args) >= 2 + payload = args[-1] + + assert isinstance(payload, dict) + assert payload['progress'] == 42.0 + assert 'app_version' not in payload + assert 'app_date' not in payload + assert 'date' not in payload