rusq / slackdump

Save or export your private and public Slack messages, threads, files, and users locally without admin privileges.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export to slack-export-viewer is not opening

eximius313 opened this issue · comments

commented

Describe the bug
The "slack-export-viewer" you recommended in this article opens "original" slack export just fine. Unfortunatelly when I try to open the export made by slackdump it throws an error:

>slack-export-viewer -z export.zip
export.zip extracting to C:\Users\User\AppData\Local\Temp\_slackviewer\zzz...
export.zip extracted to C:\Users\User\AppData\Local\Temp\_slackviewer\zzz
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\user\.local\bin\slack-export-viewer.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\slackviewer\main.py", line 61, in main
    configure_app(app, archive, channels, no_sidebar, no_external_references, debug)
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\slackviewer\main.py", line 24, in configure_app
    top.channels = reader.compile_channels(channels)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\slackviewer\reader.py", line 48, in compile_channels
    return self._create_messages(channel_names, channel_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\slackviewer\reader.py", line 189, in _create_messages
    chats = self._build_threads(chats)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\.local\pipx\venvs\slack-export-viewer\Lib\site-packages\slackviewer\reader.py", line 230, in _build_threads
    item_lookup_key = (item['user'], item['ts'])
                       ~~~~^^^^^^^^
KeyError: 'user'

To Reproduce
Steps to reproduce the behavior:

  1. Run slackdump like this 'slackdump.exe'
  2. Choose Export
  3. export.zip as Output dir
  4. Export messages
  5. Run slack-export-viewer -z export.zip

Expected behavior
slack-export-viewer can read export generated by slackdump

Desktop (please complete the following information):

  • OS: Windows 11
commented

Hey @eximius313 , out of interest, could you try opening the same export file with SlackLogViewer? https://github.com/thayakawa-gh/SlackLogViewer/releases

commented

Also, which version of slackdump did you use?

commented

Also, which version of slackdump did you use?

2.4.0 Windows_x86_64

commented

Hey @eximius313 , out of interest, could you try opening the same export file with SlackLogViewer? https://github.com/thayakawa-gh/SlackLogViewer/releases

this app works, although images are not loaded

commented

I was not able to reproduce this on any workspaces that I have available, but it looks like there's a message in your export, that has an incomplete "replies" entry.

Consider this excerpt taken from a valid export file, i.e. 2022-01-01.json in a public channel, that has one reply:

// ...
   "ts": "1579555974.009000",
    "thread_ts": "1579555974.009000",
    "last_read": "1579562553.009200",
    "subscribed": true,
    "reply_count": 1,
    "replies": [
      {
        "user": "US6CXSEBU",
        "ts": "1579562553.009200"
      }
    ],
    "latest_reply": "1579562553.009200",
//...

Slack export viewer crashes on assembling an item lookup key:

item_lookup_key = (item['user'], item['ts'])

reporting that "item" does not have a 'user' key, that can only happen in one situation: somewhere in your export file there's a malformed entry, that may look like this (ts value will be different):

    "replies": [
      {
        "ts": "1579562553.009200"
      }
   ]

This part is fetched and saved "as is" from slack API output, so it seems that there might have been a glitch during the export session.

I assume that you won't be able to share the export file with me to examine, so could you help me and confirm that this is the case by locating this anomaly in the export file that is failing to be opened by slack export viewer?

If you are able to find the file with the malformed entry, you will know the channel name. And if you do, are you able to run the export of this channel again and see if the slack export viewer opens it?

commented

I wrote a simple test file and removed the "user" from the file that I used as an example, and was able to make slack-export-viewer fail with the same error:
image

commented

Also, if you want, you can make it work by changing line 230 of reader.py to the following, as a temporary workaround:

image
commented

This works! It doesn't load images, but messages are loaded.
Is it slackdump bug, or shall I rase the issue on SlackLogViewer?

Thank you for your help!

commented

By the way - could be lack of "user" caused by "disabled" user in Slack?
Because folder names also notain Channel ID instead of disabled user's name

commented

By the way - could be lack of "user" caused by "disabled" user in Slack?
Because folder names also notain Channel ID instead of disabled user's name

This is interesting, I'll test it tomorrow and see if that is the case.

It doesn't load images, but messages are loaded.

SlackLogViewer and slack-export-viewer won't be able to show images. Difference being:

  • The original slack export does not have attachments, but the URLDownload and URLDownloadPrivate are pointing to the Slack server with an additional parameter that contains a "xoxe-..." slack export token.
  • The export files generated by slackdump have attachments downloaded, but of course the viewers know nothing about them. If you have an application, bot or legacy token that can access files throught the slack workspace, you can use the command line flag -export-token, or specify SLACK_FILE_TOKEN parameter, while invoking the export, and Slackdump will append this token to all file URLs.
      -export-token string
    	    Slack token that will be added to all file URLs, (environment: SLACK_FILE_TOKEN)
    

I feel that I need to write my own slack export viewer at some point, but I lack frontend skills, and CSS, JS and HTML are not my cup of tea.

commented

I submitted the PR to the slack-export-viewer that addresses this panic, the author of slack-export-viewer is usually pretty fast to reply. FYI: hfaran/slack-export-viewer#167

commented

The slack-export-viewer PR was merged!

commented

Thanks!

By the way - could be lack of "user" caused by "disabled" user in Slack? Because folder names also notain Channel ID instead of disabled user's name

Were you able to investigate this missing username in export issue?

commented

Hey @eximius313 , I created a new issue just for this, #224, not to lose it from the radar. Will check when able.

commented

thanks!