maxcountryman / maxcountryman/flask-bcrypt

TypeError in function

Open
#93 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
327
Forks
65
PR merge metrics
No merged PRs in 30d

Description

In flask_bcrypt.py, I noticed a TypeError in (commit d9064521998846a59a98f311e3bd135e1dfe082c) function Bcrypt.generate_password_hash() as:

TypeError: gensalt() got an unexpected keyword argument 'rounds'

Complete error

Traceback (most recent call last):
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask/app.py", line 1498, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask/app.py", line 1476, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/urmom/python/school-flask/app.py", line 116, in admin_login
    pwhash = bcrypt.generate_password_hash(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/amarnathk/.local/lib/python3.12/site-packages/flask_bcrypt.py", line 199, in generate_password_hash
    salt = bcrypt.gensalt(rounds=rounds, prefix=prefix)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: gensalt() got an unexpected keyword argument 'rounds'

As far as I know, bcrypt.gensalt(rounds=rounds, prefix=prefix) should be bcrypt.gensalt(log_rounds=rounds, prefix=prefix).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in flask_bcrypt.py at Bcrypt.generate_password_hash(), where the traceback shows bcrypt.gensalt() is called with rounds. Check the installed bcrypt API and the surrounding password-hashing behavior. Done means the function no longer raises this TypeError and password-hash generation still works with the requested rounds and prefix.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.