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

[BUG] Helix api returns no data when streamer goes online #110

Open
gigili opened this issue Jun 16, 2022 · 1 comment
Open

[BUG] Helix api returns no data when streamer goes online #110

gigili opened this issue Jun 16, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@gigili
Copy link

gigili commented Jun 16, 2022

Describe the bug
Noticed in the app container logs that it throws errors regarding an API call to twitch Helix for when the streamer goes online (might be also for offline) . It doesn't break the app in any way from what I can see as everything keeps works but I can see that error message recurring in the logs.

To Reproduce

  1. Go to the Streamers section
  2. Add a streamer to the list
  3. Wait for them to go online

Expected behavior
Swallow the error in this case as it seems like the output of that response is not needed atm

Here is the full error log from the container:

server stderr | ERROR Internal Server Error: /api/v1/twitch-events/stream-online/webhook/
server stderr | Traceback (most recent call last):
server stderr |   File "/usr/local/lib/python3.8/site-packages/asgiref/sync.py", line 472, in thread_handler
server stderr |     raise exc_info[1]
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 38, in inner
server stderr |     response = await get_response(request)
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 233, in _get_response_async
server stderr |     response = await wrapped_callback(request, *callback_args, **callback_kwargs)
server stderr |   File "/usr/local/lib/python3.8/site-packages/asgiref/sync.py", line 435, in __call__
server stderr |     ret = await asyncio.wait_for(future, timeout=None)
server stderr |   File "/usr/local/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
server stderr |     return await fut
server stderr |   File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
server stderr |     result = self.fn(*self.args, **self.kwargs)
server stderr |   File "/usr/local/lib/python3.8/site-packages/asgiref/sync.py", line 476, in thread_handler
server stderr |     return func(*args, **kwargs)
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
server stderr |     return view_func(*args, **kwargs)
server stderr |   File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
server stderr |     return self.dispatch(request, *args, **kwargs)
server stderr |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
server stderr |     response = self.handle_exception(exc)
server stderr |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
server stderr |     self.raise_uncaught_exception(exc)
server stderr |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
server stderr |     raise exc
server stderr |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
server stderr |     response = handler(request, *args, **kwargs)
server stderr |   File "/code/./tau/twitchevents/views.py", line 106, in webhook
server stderr |     streamer.save()
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
server stderr |     self.save_base(using=using, force_insert=force_insert,
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 801, in save_base
server stderr |     post_save.send(
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 177, in send
server stderr |     return [
server stderr |   File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 178, in <listcomp>
server stderr |     (receiver, receiver(signal=self, sender=sender, **named))
server stderr |   File "/code/./tau/streamers/signals.py", line 75, in streamer_saved
server stderr |     stream_data = data.json()["data"][0]
server stderr |   KeyError: 'data'

Notes from chat with Finite

   url = f'https://api.twitch.tv/helix/' \
      f'streams?user_login={instance.twitch_username}'
     data = requests.get(
     url,
     headers=headers
   )
  stream_data = data.json()["data"][0]

it looks like for some reason or another, that request to the helix API isn't returning data.
(at least for one of the calls to the API)
And what that is doing- is making a new "current/last stream" object, that we're not really even using anywhere right now.
so that whole section of code, probably doesn't need to be there.

@gigili gigili added the bug Something isn't working label Jun 16, 2022
@FiniteSingularity
Copy link
Member

Hi @gigili-

Apologies for the delay- I just got back into town from a trip. I'll take a closer look a bit later this week, and see what I can find.

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

No branches or pull requests

2 participants