You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tooling.apache.org by "sbp (via GitHub)" <gi...@apache.org> on 2025/11/04 20:22:50 UTC
[I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
sbp opened a new issue, #287:
URL: https://github.com/apache/tooling-trusted-releases/issues/287
API payload validation is handled by `quart_schema`, and is automated and consistent. Our HTML forms are not like that, and we need to improve them.
We take a relatively _ad hoc_ approach of re-rendering the originally requested form page in case of errors with validation errors displayed next to each individual field, and a summary flashed at the top of the page. This is great UI for users, but we don't implement this consistently because we haven't factored out the immense amount of boilerplate required. There are also some cases where we have POST buttons, which have no fields, and hence for which this pattern does not apply.
We also don't have a type safe guarantee that the validation failure branch is dealt with, whereas for example in API payload validation, decorators and Quart level handlers take care of it for us.
Ideally we fix this and not only ensure that every existing form implements it, but ensure that it's trivial to support in every new form, just as it is when we add a new API endpoint.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org
Re: [I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp commented on issue #287:
URL: https://github.com/apache/tooling-trusted-releases/issues/287#issuecomment-3491590963
Our Quart to Pydantic adapter would be part of a larger system. We want to ensure that validation always occurs, and we want to ensure that errors are always presented to the user with good UI. We want syntactic form errors to be handled automatically by virtue of the existence of the form class validators (including basic types), but we may need to perform business logic after other stages of computation, so we need to be able to perform additional validation in route handler functions with the same good UI guarantees.
One potential solution is that we serialise errors as JSON in a flash message with a `form-errors` category. We can then extract the relevant messages on their original pages. But how do we know what the original page is? Much like CSRF protection, we could add an extra automatic field to every page which registers the original URL of the submitting page. We should call this field the `error_report_url` or something along those lines, because we may want to set a custom value in some cases where we must not return to the original form even in case of errors.
We should use HTML in the flash message strings, so we should ensure that it can only be constructed with markup safe wrappers. The Quart to Pydantic adapter itself can probably go in the existing `forms.py` module.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org
Re: [I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
Posted by "dave2wave (via GitHub)" <gi...@apache.org>.
dave2wave closed issue #287: Improve HTML form validation error display and code quality
URL: https://github.com/apache/tooling-trusted-releases/issues/287
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org
Re: [I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
Posted by "dave2wave (via GitHub)" <gi...@apache.org>.
dave2wave commented on issue #287:
URL: https://github.com/apache/tooling-trusted-releases/issues/287#issuecomment-3752167534
> We should consider using [quart-csrf](https://pypi.org/project/quart-csrf/) instead so that we can remove Quart WTF, and thereby WTForms, from our dependencies.
This looks abandoned with a 0.3 release 5 years ago ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org
Re: [I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp commented on issue #287:
URL: https://github.com/apache/tooling-trusted-releases/issues/287#issuecomment-3632828809
We created a new `atr/form.py` module, and then removed `atr/forms.py` in 20c5be1bfe4da202b11f02b3007e4e1253263b9a. We no longer depend on WTForms directly, but we do depend on it through Quart WTF, which we still use for CSRF protection. We should consider using [quart-csrf](https://pypi.org/project/quart-csrf/) instead so that we can remove Quart WTF, and thereby WTForms, from our dependencies.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org
Re: [I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
Posted by "dave2wave (via GitHub)" <gi...@apache.org>.
dave2wave commented on issue #287:
URL: https://github.com/apache/tooling-trusted-releases/issues/287#issuecomment-3752168705
@sbp I think that this can be closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org
Re: [I] Improve HTML form validation error display and code quality (tooling-trusted-releases)
Posted by "sbp (via GitHub)" <gi...@apache.org>.
sbp commented on issue #287:
URL: https://github.com/apache/tooling-trusted-releases/issues/287#issuecomment-3491525217
Quart Schema itself [has a mechanism for parsing HTML forms](https://quart-schema.readthedocs.io/en/latest/how_to_guides/request_validation.html#form-data):
> If the request body is form (application/x-www-form-urlencoded) encoded the `source` argument can be changed to validate the form data
But I don't suggest we use it, for two reasons.
[Issue #93 with Quart Schema](https://github.com/pgjones/quart-schema/issues/93) means that we cannot use the code as is. The issue was opened on 11 Nov 2024, nearly a year ago, and hasn't received a single comment. I wrote a patch which makes it work for ATR, but my fix does not handle the many edge cases that would be necessary for upstreaming to Quart Schema. I've mentioned my basic design in the original issue. That the issue exists and has not been addressed for a year indicates that not many people are using Quart Schema for parsing HTML forms; it indicates that there may be other rough edges.
Another problem with Quart Schema is its application model and error mode handling. You have to use it as a decorator, and it changes the argument structure, but we already do the same for our routes in ATR and this would create a complex interaction. I'm sure that this can be solved, but composing conflicting decorators in this way leads to complicated higher order programming with types that are difficult to understand and maintain. Moreover, errors must be handled at the Quart level, which means that our route handlers wouldn't get to see them. This would be fine if we could put all the logic in the Quart level error handler, but it's not clear how we would do that without making significant architectural changes anyway.
Therefore I suggest that we make our own Quart to Pydantic adapter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tooling.apache.org
For additional commands, e-mail: dev-help@tooling.apache.org