Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bill Type: Invalid Choice: could not coerce. #1293

Closed
rriski opened this issue Mar 22, 2024 · 3 comments · Fixed by #1294
Closed

Bill Type: Invalid Choice: could not coerce. #1293

rriski opened this issue Mar 22, 2024 · 3 comments · Fixed by #1294
Labels

Comments

@rriski
Copy link
Contributor

rriski commented Mar 22, 2024

After #1290 I receive "Bill Type: Invalid Choice: could not coerce" when attempting to add new bills. Changing the bill type doesn't help.

The request that is going out to POST /<project>/add:

csrf_token=...
date=2024-03-22
bill_type=BillType.EXPENSE
what=test
payer=10
amount=1
payed_for=1
payed_for=2
submit=Submit

I believe the issue could be in how the BillType enum is coerced by WTForms, see https://stackoverflow.com/a/49376245. BillType doesn't have a coerce classmethod:

class BillType(Enum):
EXPENSE = "Expense"
REIMBURSEMENT = "Reimbursement"
@classmethod
def choices(cls):
return [(choice, choice.value) for choice in cls]
.

I'm running the ihatemoney/ihatemoney:master docker image. Here are my pip dependencies:

/ # pip3 list
Package              Version      Editable project location
-------------------- ------------ -------------------------
alembic              1.13.1
aniso8601            9.0.1
Babel                2.14.0
blinker              1.7.0
cachetools           4.2.4
certifi              2024.2.2
charset-normalizer   3.3.2
click                8.1.7
commonmark           0.9.1
debts                0.5
Deprecated           1.2.14
dnspython            2.6.1
email_validator      2.1.1
Flask                2.3.3
flask-babel          3.1.0
Flask-Cors           3.0.10
Flask-Limiter        2.9.2
Flask-Mail           0.9.1
Flask-Migrate        4.0.7
Flask-RESTful        0.3.10
Flask-SQLAlchemy     2.5.1
flask-talisman       1.1.0
Flask-WTF            1.2.1
greenlet             3.0.3
gunicorn             21.2.0
idna                 3.6
ihatemoney           6.2.0.dev0   /src
importlib_resources  6.3.2
itsdangerous         2.1.2
Jinja2               3.1.3
limits               3.10.1
Mako                 1.3.2
MarkupSafe           2.1.5
ordered-set          4.1.0
packaging            24.0
pip                  23.0.1
psycopg2-binary      2.9.9
Pygments             2.17.2
PyMySQL              1.0.3
pypng                0.20220715.0
python-dateutil      2.9.0.post0
pytz                 2024.1
qrcode               7.4.2
requests             2.31.0
rich                 12.6.0
setuptools           65.5.1
six                  1.16.0
SQLAlchemy           1.4.52
SQLAlchemy-Continuum 1.4.1
SQLAlchemy-Utils     0.41.1
typing_extensions    4.10.0
urllib3              2.2.1
Werkzeug             2.3.8
wheel                0.43.0
wrapt                1.16.0
WTForms              3.1.2

Screenshot from 2024-03-22 23-19-44

@zorun zorun added the bug label Mar 23, 2024
@zorun
Copy link
Collaborator

zorun commented Mar 23, 2024

Ping @TomRoussel

rriski added a commit to rriski/ihatemoney that referenced this issue Mar 23, 2024
rriski added a commit to rriski/ihatemoney that referenced this issue Mar 23, 2024
@rriski
Copy link
Contributor Author

rriski commented Mar 23, 2024

Opened a PR with a fix #1294

rriski added a commit to rriski/ihatemoney that referenced this issue Mar 23, 2024
@TomRoussel
Copy link
Contributor

Hmm, I did manually test the form at one point. But I think I changed the way the frontend showed the bill type choices since then, sorry! I'll also have a look at the PR :)

rriski added a commit to rriski/ihatemoney that referenced this issue Mar 24, 2024
rriski added a commit to rriski/ihatemoney that referenced this issue Mar 26, 2024
rriski added a commit to rriski/ihatemoney that referenced this issue Mar 26, 2024
rriski added a commit to rriski/ihatemoney that referenced this issue Mar 28, 2024
Error introduced in spiral-project#1290. Fixes spiral-project#1293. WTForms needs to be bumped to >=2.3.2
as it includes a fix to `SelectField` which is required for this change to work.

See:
  - https://wtforms.readthedocs.io/en/3.1.x/changes/#version-2-3-2
  - pallets-eco/wtforms#598
zorun pushed a commit that referenced this issue Mar 28, 2024
Error introduced in #1290. Fixes #1293. WTForms needs to be bumped to >=2.3.2
as it includes a fix to `SelectField` which is required for this change to work.

See:
  - https://wtforms.readthedocs.io/en/3.1.x/changes/#version-2-3-2
  - pallets-eco/wtforms#598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants