slack-export-viewer icon indicating copy to clipboard operation
slack-export-viewer copied to clipboard

KeyError when pointing viewer to .zip

Open skylerheise opened this issue 5 years ago • 5 comments

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.

skylerheise avatar Sep 18 '19 16:09 skylerheise

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.

hfaran avatar Sep 19 '19 07:09 hfaran

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 avatar Sep 20 '19 17:09 skylerheise

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

skylerheise avatar Sep 23 '19 19:09 skylerheise

Same error as above.

ghost avatar Nov 11 '19 18:11 ghost

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.

jwh1981 avatar Jul 14 '20 14:07 jwh1981