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

slack-machine crashes with error wrong value type for field "topic.creator" - should be "str" instead of value "None" #397

Closed
michaelbutler opened this issue Aug 5, 2020 · 4 comments · Fixed by #439

Comments

@michaelbutler
Copy link

Hi, I'm trying to test out slack-machine. I'm on Python 3.7 with latest version installed: Version: 0.20.1.

I only have the HelloPlugin enabled, when I run slack-machine in DEBUG mode I see a lot of API requests going through successfully, it appears to be paginating through channels and users and conversations, however it always gets to this point and crashes with error:

[2020-08-05 19:04:36][ERROR] slack.rtm.client client.py:_dispatch_event:505 | When calling '#_on_open()' in the 'machine.clients.singletons.slack' module the following error was raised: wrong value type for field "topic.creator" - should be "str" instead of value "None" of type "NoneType"
Traceback (most recent call last):
  File "/usr/local/bin/slack-machine", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/machine/bin/run.py", line 14, in main
    bot.run()
  File "/usr/local/lib/python3.7/site-packages/machine/core.py", line 211, in run
    self._dispatcher.start()
  File "/usr/local/lib/python3.7/site-packages/machine/dispatch.py", line 34, in start
    self._client.start()
  File "/usr/local/lib/python3.7/site-packages/machine/clients/singletons/slack.py", line 121, in start
    self.rtm_client.start()
  File "/usr/local/lib/python3.7/site-packages/slack/rtm/client.py", line 206, in start
    return self._event_loop.run_until_complete(future)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/site-packages/slack/rtm/client.py", line 361, in _connect_and_read
    await self._dispatch_event(event="open", data=data)
  File "/usr/local/lib/python3.7/site-packages/slack/rtm/client.py", line 500, in _dispatch_event
    callback(**payload)
  File "/usr/local/lib/python3.7/site-packages/machine/clients/singletons/slack.py", line 74, in _on_open
    self._register_channel(c)
  File "/usr/local/lib/python3.7/site-packages/machine/clients/singletons/slack.py", line 49, in _register_channel
    channel = Channel.from_api_response(channel_response)
  File "/usr/local/lib/python3.7/site-packages/machine/models/channel.py", line 50, in from_api_response
    return from_dict(data_class=Channel, data=user_reponse)
  File "/usr/local/lib/python3.7/site-packages/dacite/core.py", line 60, in from_dict
    value = _build_value(type_=field.type, data=transformed_value, config=config)
  File "/usr/local/lib/python3.7/site-packages/dacite/core.py", line 83, in _build_value
    return _build_value_for_union(union=type_, data=data, config=config)
  File "/usr/local/lib/python3.7/site-packages/dacite/core.py", line 94, in _build_value_for_union
    return _build_value(type_=types[0], data=data, config=config)
  File "/usr/local/lib/python3.7/site-packages/dacite/core.py", line 87, in _build_value
    return from_dict(data_class=type_, data=data, config=config)
  File "/usr/local/lib/python3.7/site-packages/dacite/core.py", line 65, in from_dict
    raise WrongTypeError(field_path=field.name, field_type=field.type, value=value)
dacite.exceptions.WrongTypeError: wrong value type for field "topic.creator" - should be "str" instead of value "None" of type "NoneType"

I'm guessing this is a simple case of the Slack API returning something that we didn't expect, so I guess slack-machine must be made to treat topic.creator as None or even handling the fact that it might not exist. If you have any ideas how I could fix this locally please let me know.

@michaelbutler
Copy link
Author

When looking through slack API docs, I'm wondering if this could happen when the user who initially setTopic
on the conversation or channel is a deleted user. I mean it probably still should be empty string "" but for whatever reason maybe they returned null or not anything at all.

@DonDebonair
Copy link
Owner

Yep, that could be it. In any case, the fix it easy. I'll make the creator optional.

@drdarina
Copy link

Has this been fixed? I'm also getting the same error

@eguven
Copy link
Contributor

eguven commented Feb 4, 2021

I'm wondering if this could happen when the user who initially setTopic on the conversation or channel is a deleted user.

@michaelbutler I checked. It was happening on a shared channel where the user who most recently set the topic was still active member of our workspace (so no reason for the value to be None).

I think in our case, the person who setTopic before (member of the other Org) did so prior to sharing the channel and this causes the None. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants