Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Just released WTForms 3.1.0 break FAB widgets (including just released 4.3.8) #2137

Closed
potiuk opened this issue Oct 14, 2023 · 0 comments · Fixed by #2138
Closed

Just released WTForms 3.1.0 break FAB widgets (including just released 4.3.8) #2137

potiuk opened this issue Oct 14, 2023 · 0 comments · Fixed by #2138

Comments

@potiuk
Copy link
Contributor

potiuk commented Oct 14, 2023

The WTForms 3.1.0 introduced a change that breaks implementation of Flask App Builder choices fields based on QuerySelectField.

The problem is that the new choices widget returns now possible "render_kwargs" parameter in "iter_choices" :

See the release notes for 3.1.0

The issue in WTForms is: pallets-eco/wtforms#692
The PR in WTForms is: https://github.com/wtforms/wtforms/pull/739/files

the change is that "choices" widget expects now 4 values to unpack in SelectFieldBase.iter_choices (value, label, selected, render_kw) where previously there were three (value, label, selected). Unfortunately Flask App builder overrides implementation of the iter_choices in QuerySelectField

def iter_choices(self):
- the iter_choices method still returns 3 values which means that when core WTF iterates over the field to display their value here: https://github.com/wtforms/wtforms/pull/739/files#diff-70bc7290d3bd4ce3f5436885709a6b8af1086763e4699598e578ee809027eadbR365 it fails with

>           for val, label, selected, render_kw in field.iter_choices():
E           ValueError: not enough values to unpack (expected 4, got 3)

Environment

Flask-Appbuilder version: Tested with 4.3.6, 4.3.7, 4.3.8 (but previous versions are also affected)
WTForms 3.1.0

pip freeze output:

pip freeze | grep -E "(Flask-App|WTForms)"

Flask-AppBuilder==4.3.8
WTForms==3.1.0

Describe the expected results

When instantiating any choice widgets in WTForms 3.1.0 and installing QuerySelectMultipleField

>           for val, label, selected, render_kw in field.iter_choices():
E           ValueError: not enough values to unpack (expected 4, got 3)

What should happen - it should not raise the exception.

I am not sure how to easily - minimally - reproduce it but the root cause of the problem is quite clear - It has been detected by the canary build in Apache Airflow (when WTForms got automatically upgraded to 3.1.0 which is compatible with FAB). FAB has WTForms<4, so anyone installing new FAB with latest compatible WTFOrms will have this problem.

You can see example failure here: https://github.com/apache/airflow/actions/runs/6516454013/job/17700187383#step:6:12162

However simply using and displaying QuerySelectMultipleField should trigger it.

potiuk added a commit to potiuk/airflow that referenced this issue Oct 14, 2023
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137
potiuk added a commit to apache/airflow that referenced this issue Oct 14, 2023
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137
potiuk added a commit to apache/airflow that referenced this issue Oct 29, 2023
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137

(cherry picked from commit 6b5d369)
ahidalgob pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue May 15, 2024
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137

(cherry picked from commit 6b5d3697f593d5e21f4b9c17a76ef07dcac26b46)

GitOrigin-RevId: d620b961540c3bf96c2df0d513b3de63081c3aa6
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Jul 18, 2024
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137

GitOrigin-RevId: 6b5d3697f593d5e21f4b9c17a76ef07dcac26b46
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Sep 20, 2024
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137

GitOrigin-RevId: 6b5d3697f593d5e21f4b9c17a76ef07dcac26b46
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue Nov 8, 2024
WTForms 3.1.0 released 10th of October 2023 introduced a breaking change in the way
QuerySelectChoices fields are handled.
See details in dpgaspar/Flask-AppBuilder#2137

GitOrigin-RevId: 6b5d3697f593d5e21f4b9c17a76ef07dcac26b46
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants