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

Not able to view the exported dump #170

Open
jaikumar-ganesan-zoomrx opened this issue Sep 29, 2023 · 6 comments
Open

Not able to view the exported dump #170

jaikumar-ganesan-zoomrx opened this issue Sep 29, 2023 · 6 comments

Comments

@jaikumar-ganesan-zoomrx

Hi we tried exporting the complete dump, however while accessing we are getting the following error:

ERROR:root:unable to find user in and I get a JSON data which has sensitive info, followed by

127.0.0.1 - - [29/Sep/2023 13:50:44] "GET / HTTP/1.1" 500 -
INFO:werkzeug:127.0.0.1 - - [29/Sep/2023 13:50:44] "GET / HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/werkzeug/serving.py", line 364, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.10/dist-packages/werkzeug/serving.py", line 325, in execute
application_iter = app(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2213, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2193, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/app.py", line 93, in index
return channel_name(channels[0])
File "/usr/local/lib/python3.10/dist-packages/slackviewer/app.py", line 19, in channel_name
return flask.render_template("viewer.html", messages=messages,
File "/usr/local/lib/python3.10/dist-packages/flask/templating.py", line 151, in render_template
return _render(app, template, context)
File "/usr/local/lib/python3.10/dist-packages/flask/templating.py", line 132, in _render
rv = template.render(context)
File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/templates/viewer.html", line 64, in top-level template code
{{render_message(message, None, no_external_references)}}
File "/usr/local/lib/python3.10/dist-packages/jinja2/runtime.py", line 777, in _invoke
rv = self._func(*arguments)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/templates/util.html", line 16, in template


File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 485, in getattr
return getattr(obj, attribute)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/message.py", line 108, in id
return self.time
File "/usr/local/lib/python3.10/dist-packages/slackviewer/message.py", line 51, in time
tsepoch = float(self._message["ts"].split(".")[0])
KeyError: 'ts'
ERROR:werkzeug:Error on request:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/werkzeug/serving.py", line 364, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.10/dist-packages/werkzeug/serving.py", line 325, in execute
application_iter = app(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2213, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2193, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.10/dist-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/app.py", line 93, in index
return channel_name(channels[0])
File "/usr/local/lib/python3.10/dist-packages/slackviewer/app.py", line 19, in channel_name
return flask.render_template("viewer.html", messages=messages,
File "/usr/local/lib/python3.10/dist-packages/flask/templating.py", line 151, in render_template
return _render(app, template, context)
File "/usr/local/lib/python3.10/dist-packages/flask/templating.py", line 132, in _render
rv = template.render(context)
File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/templates/viewer.html", line 64, in top-level template code
{{render_message(message, None, no_external_references)}}
File "/usr/local/lib/python3.10/dist-packages/jinja2/runtime.py", line 777, in _invoke
rv = self._func(*arguments)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/templates/util.html", line 16, in template

File "/usr/local/lib/python3.10/dist-packages/jinja2/environment.py", line 485, in getattr
return getattr(obj, attribute)
File "/usr/local/lib/python3.10/dist-packages/slackviewer/message.py", line 108, in id
return self.time
File "/usr/local/lib/python3.10/dist-packages/slackviewer/message.py", line 51, in time
tsepoch = float(self._message["ts"].split(".")[0])
KeyError: 'ts'

@MuratDoganer
Copy link
Contributor

Hey,

Looks like you are coming across the time stamp bug, this is due to how Slack formats time stamps from bots. To fix this you need to make a simple modification to the message.py file, just paste this in place of the existing code at line 49:

    def time(self):
        # Handle this: "ts": "1456427378.000002"
        try:
            tsepoch = float(self._message["ts"].split(".")[0])
        except KeyError:
            tsepoch = 0.0  # or any default value or handling logic you prefer

Make sure you are using a text editor like Sublime (which is free) so you can locate the line easily. As for the location of the file itself, you can find it in /usr/local/lib/python3.10/dist-packages/slackviewer/message.py

Let me know if this works for you!

@mikebrogan
Copy link

Thank you for this code, it does solve the issue for me, but does introduce another issue in that I lose all of the dates/times. Do you know how to fix that?

@MuratDoganer
Copy link
Contributor

Thank you for this code, it does solve the issue for me, but does introduce another issue in that I lose all of the dates/times. Do you know how to fix that?

Try:

def time(self):
    # Check if 'ts' key exists in the dictionary
    if "ts" in self._message:
        # Handle this: "ts": "1456427378.000002"
        tsepoch = float(self._message["ts"].split(".")[0])
        return str(datetime.datetime.fromtimestamp(tsepoch)).split('.')[0]
    else:
        return None  # or return a suitable default value

@hfaran
Copy link
Owner

hfaran commented Nov 17, 2023

@MuratDoganer If this is a broadly applicable fix, please submit a PR so that everyone can take advantage of it. Thanks.

@merobi-hub
Copy link
Contributor

Can confirm that the fix by @MuratDoganer works

@MuratDoganer
Copy link
Contributor

@MuratDoganer If this is a broadly applicable fix, please submit a PR so that everyone can take advantage of it. Thanks.

Sure thing, happy to contribute

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

5 participants