Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: KeyError: 'data' #593

Closed
ProfessionalGuardDog opened this issue Sep 12, 2024 · 10 comments
Closed

Error: KeyError: 'data' #593

ProfessionalGuardDog opened this issue Sep 12, 2024 · 10 comments
Assignees
Labels
🐜 bug Something isn't working ☑ kinda-fixed

Comments

@ProfessionalGuardDog
Copy link

Describe the bug

There seems to be an incorrect key path / name in the code, causing the following error (using the docker image):

miner_1  | 10/09/24 12:11:37 - ERROR - [post_gql_request]: Error with GQLOperations (PlaybackAccessToken): Expecting value: line 2 column 1 (char 1)
miner_1  | 10/09/24 12:11:37 - ERROR - [send_minute_watched_events]: Exception raised in send minute watched
miner_1  | Traceback (most recent call last):
miner_1  |   File "/usr/src/app/TwitchChannelPointsMiner/classes/Twitch.py", line 495, in send_minute_watched_events
miner_1  |     signature = responsePlaybackAccessToken["data"]['streamPlaybackAccessToken']["signature"]
miner_1  |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
miner_1  | KeyError: 'data'

(not including my username for privacy)

Steps to reproduce

  1. Use sudo docker-compose logs -f to view a live log of the miner

The events I am using are Events.STREAMER_ONLINE, Events.STREAMER_OFFLINE, Events.GAIN_FOR_RAID, Events.GAIN_FOR_CLAIM, Events.GAIN_FOR_WATCH, Events.BONUS_CLAIM, Events.BET_WIN, Events.BET_LOSE, Events.BET_REFUND, Events.BET_FILTERS, Events.BET_GENERAL, Events.BET_FAILED, Events.BET_START, Events.MOMENT_CLAIM, Events.JOIN_RAID, Events.DROP_CLAIM, Events.DROP_STATUS, Events.CHAT_MENTION

Expected behavior

Should return the watched time in minutes

Operating system

Linux (Debian AWS)

Python version

3.11.1

Miner version

Docker image

Other relevant software versions

No response

Logs

10/09/24 12:11:37 - ERROR - TwitchChannelPointsMiner.classes.Twitch - [send_minute_watched_events]: Exception raised in send minute watched
Traceback (most recent call last):
File "/usr/src/app/TwitchChannelPointsMiner/classes/Twitch.py", line 495, in send_minute_watched_events
signature = responsePlaybackAccessToken["data"]['streamPlaybackAccessToken']["signature"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'

Additional context

No response

@ProfessionalGuardDog ProfessionalGuardDog changed the title Error: Error: KeyError: 'data' Sep 12, 2024
@villario
Copy link

Do you use some other miner with this one? (running in parallel. i.e. Twitch Drops Miner) I have a feeling that these 2 miners unable to work side-by-side - Drops Miner start to post messages from Points Miner's channels and Drops Miner stop working correctly. And, I assume, because 2 miners are running at the same time, Points Miner start to show send_minute_watched_events and post_gql_request errors and it's because this is some sort of Twitch's protection against the DDOS (multiple requests from different scripts at the same time)

@ProfessionalGuardDog
Copy link
Author

Hey there, I am not using any miners or anything at all on the system. It's an dedicated linux (debian) system running the docker image, nothing else.

@sametguzeldev
Copy link

I started to get the same error.

@VaporyCoder
Copy link

VaporyCoder commented Oct 6, 2024

i too get the error but the script still runs normally it just will log the error in the middle of my claim logs

06/10/24 01:01:34 AM - ERROR - [post_gql_request]: Error with GQLOperations (PlaybackAccessToken): Expecting value: line 2 column 1 (char 1)
06/10/24 01:01:34 AM - ERROR - [send_minute_watched_events]: Exception raised in send minute watched
Traceback (most recent call last):
  File "C:\Users\jlara\Twitch-Channel-Points-Miner-v2-1.9.7\Twitch-Channel-Points-Miner-v2-1.9.7\TwitchChannelPointsMiner\classes\Twitch.py", line 495, in send_minute_watched_events
    signature = responsePlaybackAccessToken["data"]['streamPlaybackAccessToken']["signature"]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'data'
06/10/24 01:01:49 AM - INFO - [on_message]: 🚀  +10 → Streamer(username=anylove_, channel_id=515441123, channel_points=70.63k) - Reason: WATCH.
06/10/24 01:05:57 AM - INFO - [on_message]: 🚀  +12 → Streamer(username=presidentlemons, channel_id=67568231, channel_points=62.44k) - Reason: WATCH.
06/10/24 01:05:57 AM - INFO - [claim_bonus]: 🎁  Claiming the bonus for Streamer(username=presidentlemons, channel_id=67568231, channel_points=62.44k)!
06/10/24 01:05:58 AM - INFO - [on_message]: 🚀  +60 → Streamer(username=presidentlemons, channel_id=67568231, channel_points=62.5k) - Reason: CLAIM.
06/10/24 01:06:37 AM - ERROR - [post_gql_request]: Error with GQLOperations (VideoPlayerStreamInfoOverlayChannel): Expecting value: line 2 column 1 (char 1)
06/10/24 01:06:49 AM - INFO - [on_message]: 🚀  +10 → Streamer(username=anylove_, channel_id=515441123, channel_points=70.64k) - Reason: WATCH.
06/10/24 01:10:59 AM - INFO - [on_message]: 🚀  +12 → Streamer(username=presidentlemons, channel_id=67568231, channel_points=62.51k) - Reason: WATCH.
06/10/24 01:11:48 AM - INFO - [on_message]: 🚀  +10 → Streamer(username=anylove_, channel_id=515441123, channel_points=70.65k) - Reason: WATCH.
06/10/24 01:11:48 AM - INFO - [claim_bonus]: 🎁  Claiming the bonus for Streamer(username=anylove_, channel_id=515441123, channel_points=70.65k)!
06/10/24 01:11:49 AM - INFO - [on_message]: 🚀  +50 → Streamer(username=anylove_, channel_id=515441123, channel_points=70.7k) - Reason: CLAIM.
06/10/24 01:13:47 AM - INFO - [on_pubmsg]: 💬  maybepoggers at #presidentlemons wrote: !timeout vaporycoder 1
06/10/24 01:15:59 AM - INFO - [on_message]: 🚀  +12 → Streamer(username=presidentlemons, channel_id=67568231, channel_points=62.52k) - Reason: WATCH.
06/10/24 01:16:47 AM - INFO - [on_message]: 🚀  +10 → Streamer(username=anylove_, channel_id=515441123, channel_points=70.71k) - Reason: WATCH.

@rdavydov rdavydov self-assigned this Oct 6, 2024
@rdavydov rdavydov added the 🐜 bug Something isn't working label Oct 6, 2024
@rdavydov
Copy link
Owner

rdavydov commented Oct 6, 2024

Yep, seems like Twitch has changed the response structure, need to investigate it.

@rdavydov
Copy link
Owner

rdavydov commented Oct 6, 2024

No, the structure has not changed. I think it happens when Twitch's response is completely different, like some sort of an error. The problem is that it is not happening all the time, seems like periodically or maybe even once a session. I've been running the debugger for half an hour and still haven't got such error. Maybe they are some glitches on the Twitch's side.

I guess I can just make a quick fix to ignore these errors, they don't break the miner's functionality.

@rdavydov
Copy link
Owner

rdavydov commented Oct 6, 2024

Made some improvements to not raise the KeyError and AttributeError. Should help to get less errors in the probable API changes in this part of the code. Also now it logs more detailed information about the invalid response when it occurs.
Should be also helpful to investigate in the future.

@rdavydov
Copy link
Owner

rdavydov commented Oct 6, 2024

Please check the new version 1.9.8 and report back whether this issue has been fixed.

@rdavydov rdavydov pinned this issue Oct 6, 2024
@rdavydov
Copy link
Owner

rdavydov commented Oct 6, 2024

I see it's become even worse now, more error lines. I'll try another way.

@nAgato121f
Copy link

Error with update_client_version: HTTPSConnectionPool(host='www.twitch.tv', port=443): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002C42C3AAE70>, 'Connection to www.twitch.tv timed out. (connect timeout=None)'))

I get this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐜 bug Something isn't working ☑ kinda-fixed
Projects
None yet
Development

No branches or pull requests

6 participants