PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
791 stars 163 forks source link

Fix `TypeError: 'NoneType' object is not subscriptable` #352

Closed Bluscream closed 1 year ago

Bluscream commented 1 year ago
****** MESSAGE_RE Failed! ******
Traceback (most recent call last):
  File "/home/blu/.local/lib/python3.11/site-packages/twitchio/websocket.py", line 317, in _process_data
    if parsed["action"] == "PING":
       ~~~~~~^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Pull request summary

Checklist

chillymosh commented 1 year ago
  1. What was the data being received that was failed to be parsed?
  2. Is this simply a case of you not handing message.echo?

We simply need some more information as this may not be an issue or it may be something elsewhere that needs fixing, simply returning on None may have bigger implications. What was happening when this error happened? What is your codebase?

Bluscream commented 1 year ago

What was the data being received that was failed to be parsed?

It didn't show any extra data except the one shown in the stacktrace

Is this simply a case of you not handing message.echo?

message.echo is handled as per your example

We simply need some more information as this may not be an issue or it may be something elsewhere that needs fixing,

I can only give as much info as you're asking and asmuch as i see in the console

What was happening when this error happened?

regular usage, nothing special

What is your codebase?

sorry can't share that because of licensing issues

deseipel commented 1 year ago

FYI - I got this error also and what fixed it was to remove newline chars

chillymosh commented 1 year ago

@deseipel please be more specific as part of the Twitch IRC spec requires newlines

deseipel commented 1 year ago

the bot i have posts answers from GPT3 OR ChatGPT to Twitch. ask openai to write a poem or haiku and you'll get the bug.

chillymosh commented 1 year ago

@deseipel you still haven't answered my question from Jan. I'm also not going to setup a connection to a 3rd party service which has no relevance to the libs internals.

chillymosh commented 1 year ago

The issue is the user is trying to send a new line in their message content. IRC does not accept or use new lines in message content being sent, only to terminate the websocket send.

deseipel commented 1 year ago

Interesting, thank you for finding root cause. this came up during my own testing when I was copy/pasting test messages. makes sense now. I appreciate it.