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

Form field errors not JSON serializable with default Flask JSONProvider #829

Open
jwag956 opened this issue Jan 23, 2024 · 3 comments
Open

Comments

@jwag956
Copy link

jwag956 commented Jan 23, 2024

The decision in 3.0 to use None as a dictionary key for holding form level errors #595 has the unfortunate side-effect of not allowing the JSON serializer to sort keys - which is the default set up by Flask.

One gets the error: TypeError: '<' not supported between instances of 'NoneType' and 'str'

Not sure of a good solution since it has been this way for a couple years now - a simple but not great solution would be to offer a configuration option to change the key.

I also realize that wtforms isn't explicitly tied to Flask - though as a low level library it would be nice if it didn't force the behavior of applications and higher level frameworks.

Environment

  • Python version: 3.9
  • wtforms version: 3.1.2
@davidism
Copy link
Member

I don't mind just changing it to "" or "__form__" in a feature release.

@jwag956
Copy link
Author

jwag956 commented Jan 24, 2024

Thanks - a comment in #595 suggests 'all' - same as django - I don't really care - though using anything that could be confused as core python I think would just cause confusion (also - it isn't all errors!). 'form' seems pretty safe.

@davidism
Copy link
Member

I use the empty string "" in another API library I maintain, which isn't otherwise valid as a form field name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants