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

Redis returns byte-like object instead of string so flanker crashes #241

Closed
hoppla20 opened this issue Apr 8, 2020 · 1 comment
Closed

Comments

@hoppla20
Copy link

hoppla20 commented Apr 8, 2020

After installing redis flanker crashes when I try to validate an address for the second time with following error logs:

Traceback (most recent call last):
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/data/workspace/campusjaeger/mailgun-microservice/emailValidation.py", line 27, in checkMail
    parsedAddress = address.validate_address(addressValue)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flanker/utils.py", line 64, in wrapper
    return_value = f(*args, **kwargs)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flanker/addresslib/address.py", line 322, in validate_address
    plugin = plugin_for_esp(exchanger)
  File "/data/workspace/campusjaeger/mailgun-microservice/env/lib/python3.6/site-packages/flanker/addresslib/validate.py", line 129, in plugin_for_esp
    if grammar[0].match(mail_exchanger):
TypeError: cannot use a string pattern on a bytes-like object

After tracing the error I found out, that the lookup_exchanger_in_cache method in validate.py returns a byte instead of a string.
I fixed the issue by adding decode_response=True in the redis_driver.py in line 18:

# replaced
self.r = redis.StrictRedis(host=host, port=port, db=db)
# with
self.r = redis.StrictRedis(host=host, port=port, db=db, decode_responses=True)

But I don't want to change files in the plugin so I wanted to ask whether anybody else experienced this error.

@hoppla20 hoppla20 closed this as completed Apr 8, 2020
@hoppla20
Copy link
Author

hoppla20 commented Apr 8, 2020

I just saw, that that this is a duplicate to #31

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

1 participant