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'
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
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?
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
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
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: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!
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:
@MuratDoganer If this is a broadly applicable fix, please submit a PR so that everyone can take advantage of it. Thanks.
Can confirm that the fix by @MuratDoganer works
Sure thing, happy to contribute