hfaran / slack-export-viewer

A Slack Export archive viewer that allows you to easily view and share your Slack team's export
https://pypi.python.org/pypi/slack-export-viewer
MIT License
966 stars 193 forks source link

KeyError when pointing viewer to .zip #109

Open skylerheise opened 5 years ago

skylerheise commented 5 years ago

I keep getting the following error and trace when I try to open the export viewer: Traceback (most recent call last): File "/usr/local/bin/slack-export-viewer", line 10, in sys.exit(main()) File "/Library/Python/2.7/site-packages/click/core.py", line 764, in call return self.main(args, kwargs) File "/Library/Python/2.7/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/Library/Python/2.7/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/Library/Python/2.7/site-packages/click/core.py", line 555, in invoke return callback(args, **kwargs) File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 61, in main configure_app(app, archive, channels, no_sidebar, no_external_references, debug) File "/Library/Python/2.7/site-packages/slackviewer/main.py", line 29, in configure_app top.mpim_users = reader.compile_mpim_users() File "/Library/Python/2.7/site-packages/slackviewer/reader.py", line 107, in compile_mpim_users mpim_members = {"name": mpim["name"], "users": [self.__USER_DATA[m] for m in mpim["members"]]} KeyError: u'U094J8VTL'

the window doesn't open at any point, but the process continues for a while before it crashes.

hfaran commented 5 years ago

Can you add a breakpoint on this line and see what __USER_DATA contains? Looks like for some reason that name isn't populated in the dictionary with that ID.

skylerheise commented 5 years ago

What do you mean by "add a breakpoint on this line"? I'm assuming I'm not just navigating to the user data directory path.

skylerheise commented 5 years ago

A colleague of mine tried it with a new install of the viewer, and ended up getting the same error as I did.

ghost commented 5 years ago

Same error as above.

jwh1981 commented 4 years ago

I am having the same issue. The cause of the KeyError (for us) is that the user in question is not with our organization and an outside consultant. Therefore they are single channel and not in our users.json

The issue then appears to be that, since the mpims.json has an invalid user, the program fails.

I confirmed/worked around this by doing the following:

  1. Note the KeyError. Ex. U0001112
  2. Decompress the file from Slack export
  3. Edit mpims.json and search U0001112 and delete its references
  4. Save the file
  5. Compress all of the dump as a new zip file
  6. Run the tool against the new zip.
  7. If it works, Profit! BUT if it fails, repeat steps 1-6. I only have to delete two users that were causing the KeyError and then it works.

I imagine it just needs a way, in the reader.py, to gracefully continue if a KeyError is experienced.