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

Crashes if there are canvases in the dump #4

Open
nneonneo opened this issue Aug 18, 2024 · 1 comment
Open

Crashes if there are canvases in the dump #4

nneonneo opened this issue Aug 18, 2024 · 1 comment

Comments

@nneonneo
Copy link

Some of our channels had canvases in them, which are saved as files called _channels/[cid]/canvas_in_the_conversation.json (as opposed to files named using YYYY-MM-DD.json, like all other messages).

Instead of containing messages, this file contains file entries that look like this:

[
{
    "id": "F0...",
    "created": 16...,
    "name": "Untitled",
    "title": "Untitled",
    "mimetype": "application\/vnd.slack-docs",
    "filetype": "quip",
    "pretty_type": "Canvas",
    "user": "USLACKBOT",
    "editable": true,
    "size": 35,
    "mode": "quip",
    "is_public": true,
    "is_tombstoned": false,
    "public_url_shared": false,
    "date_delete": 0,
    "url_private_download": "https:\/\/files.slack.com\/files-pri\/...",
    "shares": [
        {
            "team": "T0...",
            "channel": "C1..."
        }
    ]
}
]

Unfortunately, wayslack tries to read these as messages, and crashes with the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/wayslack", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 1513, in main
    archive.refresh()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 1293, in refresh
    sub.refresh()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 889, in refresh
    BaseArchiver.refresh(self)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 821, in refresh
    obj.refresh()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 576, in refresh
    self._refresh_messages()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 682, in _refresh_messages
    last_saved_replies_ts = get_last_saved_replies_ts()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 618, in get_last_saved_replies_ts
    for msg in sorted(self.load_messages(archive), key=lambda m: m["ts"], reverse=True):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wayslack.py", line 618, in <lambda>
    for msg in sorted(self.load_messages(archive), key=lambda m: m["ts"], reverse=True):
KeyError: 'ts'

In my case, I just deleted these canvas_in_the_conversation.json files after verifying the files they pointed to were empty canvases (just people pressing the button by accident). However, a more general solution should be to ignore these files completely.

@huyz
Copy link
Owner

huyz commented Aug 26, 2024

I'll try to take a look within the next week or two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants