Remove undocumented app metadata from scrobble payloads#105
Open
Copilot wants to merge 2 commits into
Open
Conversation
Copilot
AI
changed the title
[WIP] Fix scrobble payload to remove undocumented app metadata
Remove undocumented app metadata from scrobble payloads
May 28, 2026
433c207 to
ad1d856
Compare
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>
ad1d856 to
e857bd3
Compare
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>
7492add to
beef1b0
Compare
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.
Scrobble payloads were including
app_versionanddatefields not present in the Trakt API docs. When either isNone, the API rejects the request with400 {"error": "Expected string, received null"}.Fixes #100
Changes
trakt/sync.py:Scrobbler._post()now builds the payload with onlyprogress+ media JSON:tests/test_scrobble.py: Addedtest_scrobbler_payload_excludes_app_metadata— patchesapi().postto capture the outgoing payload and assertsapp_version,app_date, anddateare absent.Original prompt
Create a pull request in repository
glensc/python-pytraktto fix issue #100: scrobble payloads currently include undocumented app metadata that can be null and cause Trakt API 400 responses.Context:
app_version and app_date are not in Trakt API doc and may raise 400 error/scrobble/startpayload documentation only includes the media object andprogress, and that sendingapp_version: nullcan trigger400 {"error": "Expected string, received null"}.Relevant code identified:
trakt/sync.py:Scrobbler._post()currently builds payloads withprogress,app_version, anddatebefore adding the media JSON.trakt/movies.pyandtrakt/tv.py: publicscrobble()methods passapp_versionandapp_dateintoScrobbler; changing these call signatures is optional unless needed for compatibility. Keep scope minimal.checkin_media()also usesapp_versionandapp_date, but issue app_version and app_date are not in Trakt API doc and may raise 400 error #100 is specifically about scrobble payloads; do not change checkin behavior unless strictly necessary.tests/test_scrobble.py. Mock payload data also exists intests/mock_data/scrobble.json.Requirements:
app_version/app_datemetadata that may be null.Expected likely approach:
Scrobbler._post()intrakt/sync.pyso the payload contains onlyprogressplusmedia.to_json_singular()content.tests/test_scrobble.py(and any fixture/mock data if needed) to verify the scrobble payload shape and absence ofapp_version,app_date, or straydatefields.Deliverable:
maininglensc/python-pytraktwith atomic commits and a clear PR description referencing issue app_version and app_date are not in Trakt API doc and may raise 400 error #100.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Propose fix for @glensc/python-pytrakt/issues/100 issue.
When making commits, make the commits atomic, smallest as possible following guidance from https://chris.beams.io/git-commit
Assistant: Proposed fix: stop sending undocumented
app_version/app_datefields in scrobble payloads, and add a regression test that would fail if those fields reappear.Why this is the right fix
Scrobbler._post()and includesapp_versionplusdateunconditionally. That does not match the issue report or the documented Trakt scrobble payload shape.checkinstill appears intentionally built aroundapp_version/app_date, so I would not change checkin as part of issue app_version and app_date are not in Trakt API doc and may raise 400 error #100 unless you want to broaden scope.Minimal code change
In
trakt/sync.py, changeScrobbler._post()from building:to:
Regression test to add
Add a test in
tests/test_scrobble.pyasserting the generated payload does not contain those fields: