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

Error while importing one specific (public) channel #32

Closed ernestomiquel closed 6 months ago

ernestomiquel commented 6 months ago

I'm having this issue with slack-to-discord: All my import attempts fail at the same point. Lots of channels get added without issue. But import fails when attempting to import one channel (it doesn't even create this channel). And the whole import process aborts. I tried manually specifying single channels for importing, and all other channels that would follow this one import just fine. So my problem is only with this specific channel.

It's a public channel. I don't know what to do.

This is the terminal output:

INFO     slack_to_discord.importer Processing channel '#seminarios-reuniones'...
23 CRITICAL slack_to_discord.importer Failed to finish import!
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 405, in on_ready
    await self._run_import(g)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 473, in _run_import
    for msg in slack_channel_messages(self._data_dir, chan_name, self._users, emoji_map, pins):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 168, in slack_channel_messages
    for d in sorted(data, key=lambda x: x["ts"]):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 168, in <lambda>
    for d in sorted(data, key=lambda x: x["ts"]):
                                        ~^^^^^^
KeyError: 'ts'
2024-02-24 11:28:23 INFO     slack_to_discord.importer Bot logging out
pR0Ps commented 6 months ago

This looks like #28 which was fixed recently in version v1.1.6. Can you confirm you're using that version and still seeing the issue?

ernestomiquel commented 6 months ago

Yes. It's v1.1.6.

pR0Ps commented 6 months ago

Would you be willing to privately send me your export so I can take a look? (email is on profile).

pR0Ps commented 6 months ago

I've released v1.1.7 that includes more debug logging that should help diagnose this. If you aren't comfortable sending me the export can you instead upgrade to that version (pip install --upgrade slack-to-discord), re-run the import, and paste the logs here (or email them to me if they include sensitive data)?

ernestomiquel commented 6 months ago

I've upgraded to v1.1.7 and re-run the import. Here are the logs:

P.S: Thank you!

2024-02-24 17:47:00 INFO     slack_to_discord.importer Extracting Slack export zip
2024-02-24 17:47:00 INFO     slack_to_discord.importer Logging the bot into Discord
2024-02-24 17:47:00 WARNING  discord.client PyNaCl is not installed, voice will NOT be supported
2024-02-24 17:47:00 INFO     discord.client logging in using static token
2024-02-24 17:47:01 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 9c404e2f02d1045108715def53b4f760).
2024-02-24 17:47:03 INFO     slack_to_discord.importer The bot has logged in!
2024-02-24 17:47:03 INFO     slack_to_discord.importer Starting to import messages
2024-02-24 17:47:03 INFO     slack_to_discord.importer Skipping channel '#general' - not in the list of channels to import
...
... (skipped other channels)
...
2024-02-24 17:47:03 INFO     slack_to_discord.importer Processing channel '#seminarios-reuniones'...
2024-02-24 17:47:03 CRITICAL slack_to_discord.importer Failed to finish import!
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 405, in on_ready
    await self._run_import(g)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 473, in _run_import
    for msg in slack_channel_messages(self._data_dir, chan_name, self._users, emoji_map, pins):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 168, in slack_channel_messages
    for d in sorted(data, key=lambda x: x["ts"]):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 168, in <lambda>
    for d in sorted(data, key=lambda x: x["ts"]):
                                        ~^^^^^^
KeyError: 'ts'
2024-02-24 17:47:03 INFO     slack_to_discord.importer Bot logging out
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/bin/slack-to-discord", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/__main__.py", line 27, in main
    run_import(
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 562, in run_import
    raise client._exception
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 405, in on_ready
    await self._run_import(g)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 473, in _run_import
    for msg in slack_channel_messages(self._data_dir, chan_name, self._users, emoji_map, pins):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 168, in slack_channel_messages
    for d in sorted(data, key=lambda x: x["ts"]):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/slack_to_discord/importer.py", line 168, in <lambda>
    for d in sorted(data, key=lambda x: x["ts"]):
                                        ~^^^^^^
KeyError: 'ts'
pR0Ps commented 6 months ago

Not sure why this would be happening, but it looks like that's still using an older version. The traceback shows the code key=lambda x: x["ts"] but this code doesn't exist in v1.1.7 anymore. Maybe try fully uninstalling and reinstalling the package?

ernestomiquel commented 6 months ago

Well... I fully uninstalled and reinstalled it. Tried again and same output, even with the key=lambda x: x["ts"] :( BUT: Then I closed the terminal window I was using from the beginning and tried the command on a new one. And now it works just fine! It's importing.

I don't know what did the trick, so to sum it up: after uninstalling and reinstalling (v1.1.7), closing the original terminal window and running the command in a new one, everything is ok. Thank you so much!

pR0Ps commented 6 months ago

Very strange. If it works, it works!