Skip to content

[BUG] Dash with CSRFProtect from Flask-WTF no longer working after Dash 4.1 to 4.2 upgrade #3827

@ghaarsma

Description

@ghaarsma

After upgrading Dash 4.1.0 to Dash 4.2.0 (while keeping Flask-WTF at 1.3.0) the application no longer works and creates the following exception: flask_wtf.csrf.CSRFError: 400 Bad Request: The CSRF token is missing.

Everything is working fine under Dash 4.1.0. Under Dash 4.2.0 it creates the following exception during callback execution:

Traceback (most recent call last):
  File "C:\Users\Python\dash_test4\venv\Lib\site-packages\flask_wtf\csrf.py", line 286, in protect
    validate_csrf(self._get_csrf_token())
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Python\dash_test4\venv\Lib\site-packages\flask_wtf\csrf.py", line 102, in validate_csrf
    raise ValidationError("The CSRF token is missing.")
wtforms.validators.ValidationError: The CSRF token is missing.

During handling of the above exception, another exception occurred:

flask_wtf.csrf.CSRFError: 400 Bad Request: The CSRF token is missing.

A MRE to reproduce the problem is here:

dash_app.py

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions