Skip to content

Fix followed games: send the query document instead of a rotating persisted hash - #142

Open
einanderson wants to merge 1 commit into
anxdpanic:masterfrom
einanderson:fix/followed-games-persisted-query
Open

Fix followed games: send the query document instead of a rotating persisted hash#142
einanderson wants to merge 1 commit into
anxdpanic:masterfrom
einanderson:fix/followed-games-persisted-query

Conversation

@einanderson

Copy link
Copy Markdown
Contributor

"Following - Games" is empty: the route raises NotFound because Twitch answers the request with
PersistedQueryNotFound.

Cause

helix/games.py::_get_followed sends a persisted query with a hard-coded sha256Hash
(8446d4d2…). Twitch rotates those hashes, so the stored one eventually stops resolving and
the endpoint returns nothing usable.

The change

Send the full query document instead of the persisted hash:

query FollowingGames_CurrentUser($limit: Int!, $type: FollowedGamesType!) {
  currentUser { followedGames(first: $limit, type: $type) {
    nodes { id name displayName boxArtURL viewersCount } } } }

The batch form (a list) is kept, so the response shape is identical
([0].data.currentUser.followedGames.nodes) and nothing changes on the add-on side —
routes/followed.py and the converter are untouched.

Verification

Reproduced directly against gql.twitch.tv (persisted hash → PersistedQueryNotFound, full
document → the nodes), and confirmed in Kodi 21.3 on two boxes: the folder lists the followed
games again.

Note: the query still filters on type: LIVE, unchanged from before. A test without the filter
returned the same set here, so it is not the cause of an empty folder.

The follow/unfollow mutations in the same file still use persisted hashes. They are a different
matter — Twitch answers those with IntegrityCheckFailed for third-party clients regardless of
the hash, so replacing it there would not help.

_get_followed() used a hardcoded persisted-query sha256 hash. Twitch rotates
those hashes, and this one is no longer known, so the call only ever answers
with PersistedQueryNotFound and "followed games" comes up empty.

Send the full query document instead. The batched request and response shape
stay the same, and so do the returned fields (id, name, displayName,
boxArtURL, viewersCount), so callers need no change.

Verified against gql.twitch.tv with a user token: the persisted variant
returns PERSISTED_QUERY_NOT_FOUND, the query document returns the nodes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant