Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution fails with KeyError: 'replies' #121

Closed
pkaldis opened this issue Feb 27, 2020 · 6 comments · Fixed by #154
Closed

Execution fails with KeyError: 'replies' #121

pkaldis opened this issue Feb 27, 2020 · 6 comments · Fixed by #154

Comments

@pkaldis
Copy link

pkaldis commented Feb 27, 2020

Running the viewer against our data export takes a bit of time, but eventually it exits with the following error:

pkaldis@anatomy ~/Desktop/Export --> slack-export-viewer -z data_export.zip
/var/folders/gt/f1j5l07n1zd6_3r_7rz6jgzc0001g1/T/_slackviewer/90d4e276bb39a4adce4ff381bf0ce8bef12e7bf6 already exists
Traceback (most recent call last):
File "/usr/local/bin/slack-export-viewer", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/slackviewer/main.py", line 61, in main
configure_app(app, archive, channels, no_sidebar, no_external_references, debug)
File "/usr/local/lib/python2.7/site-packages/slackviewer/main.py", line 24, in configure_app
top.channels = reader.compile_channels(channels)
File "/usr/local/lib/python2.7/site-packages/slackviewer/reader.py", line 35, in compile_channels
return self._create_messages(channel_names, channel_data)
File "/usr/local/lib/python2.7/site-packages/slackviewer/reader.py", line 176, in _create_messages
chats = self._build_threads(chats)
File "/usr/local/lib/python2.7/site-packages/slackviewer/reader.py", line 199, in _build_threads
for reply in message._message['replies']:
KeyError: 'replies'

Any insights on how to troubleshooting this would be greatly appreciated.

Thank you!

@coreydeli
Copy link

Same issue here running python 2.7 and 3.6

@hfaran
Copy link
Owner

hfaran commented Mar 3, 2020

Schema might have changed in the export - can you put a breakpoint there to see what keys are in the dictionary to figure out what it might have changed to?

@coreydeli
Copy link

/tmp/_slackviewer/26b10a07947e773d8f07e2e3503d54a317f0256f already exists
Traceback (most recent call last):
  File "/home/username/.local/bin/slack-export-viewer", line 11, in <module>
    sys.exit(main())
  File "/home/username/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/username/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/username/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/username/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/username/.local/lib/python3.6/site-packages/slackviewer/main.py", line 61, in main
    configure_app(app, archive, channels, no_sidebar, no_external_references, debug)
  File "/home/username/.local/lib/python3.6/site-packages/slackviewer/main.py", line 24, in configure_app
    top.channels = reader.compile_channels(channels)
  File "/home/username/.local/lib/python3.6/site-packages/slackviewer/reader.py", line 35, in compile_channels
    return self._create_messages(channel_names, channel_data)
  File "/home/username/.local/lib/python3.6/site-packages/slackviewer/reader.py", line 176, in _create_messages
    chats = self._build_threads(chats)
  File "/home/username/.local/lib/python3.6/site-packages/slackviewer/reader.py", line 199, in _build_threads
    for reply in message._message['replies']:
KeyError: 'replies'

@landonepps
Copy link

I changed line 199 to:
for reply in message._message.get('replies', []):
just as a quick patch.

@blacky14
Copy link

blacky14 commented Apr 8, 2020

the thread replies are no longer embedded in the messages themselves.

they are now separate messages/blocks that are correlated via the thread_ts values, as also explained here: https://api.slack.com/messaging/retrieving#finding_threads

@fzimmermann89
Copy link

fzimmermann89 commented Jun 21, 2020

While looking at this, I noticed what I think might another bug/potential bug:

for answer in channel_data[channel_name]:

followed by
thread_message = channel_data[channel_name].pop(reply_location)

The for loop goes through an list and inside the body of the loop elements are removed from the list.
wouldn't this cause messages to be skipped?

trianglee added a commit to trianglee/slack-export-viewer that referenced this issue Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants