-
-
Notifications
You must be signed in to change notification settings - Fork 105
Description
When the tanner_api Docker container spins up it outputs the following error and exits
tanner_api | Traceback (most recent call last):
tanner_api | File "/opt/tanner/tanner-env/bin/tannerapi", line 4, in <module>
tanner_api | __import__('pkg_resources').run_script('Tanner==0.6.0', 'tannerapi')
tanner_api | File "/opt/tanner/tanner-env/lib/python3.9/site-packages/pkg_resources/__init__.py", line 651, in run_script
tanner_api | self.require(requires)[0].run_script(script_name, ns)
tanner_api | File "/opt/tanner/tanner-env/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1455, in run_script
tanner_api | exec(script_code, namespace, namespace)
tanner_api | File "/opt/tanner/tanner-env/lib/python3.9/site-packages/Tanner-0.6.0-py3.9.egg/EGG-INFO/scripts/tannerapi", line 20, in <module>
tanner_api | File "/opt/tanner/tanner-env/lib/python3.9/site-packages/Tanner-0.6.0-py3.9.egg/EGG-INFO/scripts/tannerapi", line 16, in main
tanner_api | File "/opt/tanner/tanner-env/lib/python3.9/site-packages/Tanner-0.6.0-py3.9.egg/tanner/api/server.py", line 116, in start
tanner_api | File "/opt/tanner/tanner-env/lib/python3.9/site-packages/Tanner-0.6.0-py3.9.egg/tanner/utils/api_key_generator.py", line 8, in generate
tanner_api | AttributeError: 'str' object has no attribute 'decode'
tanner_api exited with code 1
In the tanner documentation we can see that the api_key is appended to certain endpoints for metrics
I believe this error is due to the api_key_generator.py script using outdated syntax from a previous version of python. specifically
- The jwt.encode() function returns a string (not bytes) in the latest versions of PyJWT (>=2.0).
- Since it's already a string, calling .decode("utf-8") on it causes an error in Python 3.
One solution to this might be to change the script to something like
import jwt
from tanner.config import TannerConfig
def generate():
key = TannerConfig.get("API", "auth_signature")
encoded = jwt.encode({"user": "tanner_owner"}, key, algorithm="HS256")
if isinstance(encoded, bytes):
return encoded.decode("utf-8") # Only decode if it's bytes
return encoded # Return directly if it's already a string
Screenshot:
There is another open issue with tanner that I believe is related to this, submitted approx. 3 weeks ago without response
Please see the the following screenshots showing that...
The Tanner web instance is up:
The Snare instance is up and connected:
We can get to the primary page for the Snare instance:
The Snare-Stats Page returns a 500 error:
The Sessions Page Returns a 500 error:
Note I have not tried switching to Python 2 as the Tanner project states it was tested on Python 3.7, additionally Python 2 is severely deprecated





