pR0Ps / slack-to-discord

Import a Slack export into a Discord server
https://pypi.org/project/slack-to-discord/
76 stars 11 forks source link

Failed to finish import - KeyError 'mode' #22

Closed HappyNTH closed 1 year ago

HappyNTH commented 1 year ago

I've been trying to get the importer working, but have kept running into the following error:

CRITICAL slack_to_discord.importer Failed to finish import!
Traceback (most recent call last):
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 404, in on_ready
    await self._run_import(g)
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 472, in _run_import
    for msg in slack_channel_messages(self._data_dir, chan_name, self._users, emoji_map, pins):
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 228, in slack_channel_messages
    files = [x for x in files if x["mode"] != "tombstone" and x.get("url_private")]
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 228, in <listcomp>
    files = [x for x in files if x["mode"] != "tombstone" and x.get("url_private")]
KeyError: 'mode'
2023-03-20 12:12:05 INFO     slack_to_discord.importer Bot logging out
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.15) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/home/cu/.local/bin/slack-to-discord", line 8, in <module>
    sys.exit(main())
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/__main__.py", line 27, in main
    run_import(
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 561, in run_import
    raise client._exception
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 404, in on_ready
    await self._run_import(g)
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 472, in _run_import
    for msg in slack_channel_messages(self._data_dir, chan_name, self._users, emoji_map, pins):
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 228, in slack_channel_messages
    files = [x for x in files if x["mode"] != "tombstone" and x.get("url_private")]
  File "/home/cu/.local/lib/python3.8/site-packages/slack_to_discord/importer.py", line 228, in <listcomp>
    files = [x for x in files if x["mode"] != "tombstone" and x.get("url_private")]
KeyError: 'mode'

I'm not able to make the most sense of it myself, but I have checked both urllib3 and chardet are up-to-date (1.26.15 and 3.0.4 respectively). I'm running on WSL, since I've had separate issues getting Windows to recognise slack-to-discord after pip install-ing it

As an extra test step, I cloned the latest version of the repository locally and attempted to run the command directs (i.e. python3 __main__.py --zipfile <file> --guild <guild> --token <token> when in /slack-to-discord/slack_to_discord/), and received the same error

HappyNTH commented 1 year ago

Swift update because I've realised my mistake in cloning the repository locally: after changing __main__.py to import from local importer.py instead of slack_to_discord, the error disappeared. The issue is, in my case, because the pip version of this tool isn't up-to-date with f4b6708, which solves the error.

pR0Ps commented 1 year ago

Glad you worked it out, I'll leave this open until I push a new release with this fix in case other people have the same issue

pR0Ps commented 1 year ago

Released in v1.1.3