hypothesis / h

Annotate with anyone, anywhere.
https://hypothes.is/
BSD 2-Clause "Simplified" License
2.91k stars 425 forks source link

[passlib.handlers.bcrypt:WARNING] (trapped) error reading bcrypt version #8418

Open wenion opened 6 months ago

wenion commented 6 months ago

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin version = _bcrypt.about.version AttributeError: module 'bcrypt' has no attribute 'about'

I think the passlib v1.7.4 didn't support bcrypt v4.1.2. There is no about.py file in bcrypt v4.1.2 package

robertknight commented 4 months ago

To add context, this is a warning that appears in the logs when performing an action in Hypothesis that encrypts a password.

Steps to reproduce in development:

  1. Go to http://localhost:5000/account/settings
  2. Change your password (the new one can be the same as the old)

The following appears in the logs:

web (stderr)         | 2024-03-04 09:37:56,520 [48366] [passlib.handlers.bcrypt:WARNING] (trapped) error reading bcrypt version
web (stderr)         | Traceback (most recent call last):
web (stderr)         |   File "/Users/robert/hypothesis/h/.tox/dev/lib/python3.11/site-packages/passlib/handlers/bcrypt.py", line 620, in _load_backend_mixin
web (stderr)         |     version = _bcrypt.__about__.__version__
web (stderr)         |               ^^^^^^^^^^^^^^^^^
web (stderr)         | AttributeError: module 'bcrypt' has no attribute '__about__'

The warning on its own is harmless since the version variable here is only used to write a message to debug logs. See upstream code:

try:
    version = _bcrypt.__about__.__version__
except:
    log.warning("(trapped) error reading bcrypt version", exc_info=True)
    version = '<unknown>'

log.debug("detected 'bcrypt' backend, version %r", version)
return mixin_cls._finalize_backend_mixin(name, dryrun)
robertknight commented 4 months ago

Upstream issue: https://foss.heptapod.net/python-libs/passlib/-/issues/190. See also https://foss.heptapod.net/python-libs/passlib/-/issues/187 for general updates on passlib.