pallets-eco/flask-wtf

validate() got an unexpected keyword argument 'extra_validators'

marcdexet-cnrs opened this issue · 2 comments

Dear all

I get the error validate() got an unexpected keyword argument 'extra_validators' with the 1.1.1 version, but if I downgrade to 1.0.1, it's ok.
(version 1.1.0 give me the famous ParametersForm.validate() takes 1 positional argument but 2 were given)
It's a production application we're using for 2 years, it's not a fresh one.

Trace is the following :

ERROR:flaskapp.app:Exception on /parameters/ [POST]
Traceback (most recent call last):
  File "C:\Applications\<...>\.venv\lib\site-packages\flask\app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Applications\<...>\.venv\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Applications\<...>\.venv\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Applications\<...>\.venv\lib\site-packages\flask\app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "C:\Applications\<...>\flaskapp\app.py", line 127, in parameters
    if form.validate_on_submit():
  File "C:\Applications\<...>\.venv\lib\site-packages\flask_wtf\form.py", line 86, in validate_on_submit
    return self.is_submitted() and self.validate(extra_validators=extra_validators)
TypeError: ParametersForm.validate() got an unexpected keyword argument 'extra_validators'

Environment:

  • Python version: 3.10.0
  • Flask-WTF version: 1.1.1
  • Flask version: 2.2.2
  • Windows 10

Hi everyone!

I'm experiencing a similar issue with Flask-WTF==1.1.1:

Traceback (most recent call last):
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask/app.py", line 2548, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.handle_exception(e)
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask_security/decorators.py", line 230, in wrapper
    return f(*args, **kwargs)
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask_security/views.py", line 77, in login
    if form.validate_on_submit():
  File "/home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask_wtf/form.py", line 86, in validate_on_submit
    return self.is_submitted() and self.validate(extra_validators=extra_validators)
TypeError: validate() got an unexpected keyword argument 'extra_validators'

Then if I open: /home/lucas/.pyenv/versions/3.8.15/envs/relog3p/lib/python3.8/site-packages/flask_wtf/form.py and at line 86 leave:

return self.is_submitted() and self.validate()

Things work as expected. I'm experiencing this error while trying to access a protected URL with the Flask-Security
plugin but as the trace shows is not directly related to it.

Downgrading as recommended by @marcdexet-cnrs seems to fix the issue. These are the flask related packages installed
in my virtual environment that produce the above trace:

Flask==2.2.2
Flask-BabelEx==0.9.4
Flask-Bcrypt==1.0.1
Flask-JWT-Extended==4.4.3
Flask-Login==0.6.2
Flask-Mail==0.9.1
Flask-Principal==0.4.0
Flask-Security==3.0.0
flask-shell-ipython==0.4.1
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.1.1

Thanks,
Lucas.

Duplicate of #547