Improve instance form errors #173

Merged
tobru merged 3 commits from 164-keep-values-on-error into main 2025-09-12 07:21:30 +00:00
Member

ref #164

I was not able to reproduce the issue with the missing form values in either Firefox or Chrome by manually injecting an exception in the process, and from what I can tell, we are already doing the right thing in Django (using form_invalid() in the view when errors occur). I improved the error placement and logic a bit while looking at this, but not sure where to begin to reproduce the actual problem.

ref #164 I was not able to reproduce the issue with the missing form values in either Firefox or Chrome by manually injecting an exception in the process, and from what I can tell, we are already doing the right thing in Django (using `form_invalid()` in the view when errors occur). I improved the error placement and logic a bit while looking at this, but not sure where to begin to reproduce the actual problem.
Owner

Created a liitle screencast of what I observed, even with this PR

Created a liitle screencast of what I observed, even with this PR
rixx force-pushed 164-keep-values-on-error from f0b724f26a to 5933352f5f 2025-09-11 11:24:30 +00:00 Compare
Author
Member

The screencast shows you saving the form after entering only the name, which should be impossible now that the required field detection is fixed, right?

The fact that required fields are now listed correctly makes pretty hard to reproduce the problem, but it will still occur if the instance creation or server-side validation fails.

The problem seems to be with the spec.parameters.service.fqdn field, which the browser displays with its previously entered value, but on form submission, the browser sends a "[", which the server correctly rejects – and then, of course on the second page render with errors, the previous user input is missing, as it never made its way back to the server.

The screencast shows you saving the form after entering only the name, which should be impossible now that the required field detection is fixed, right? The fact that required fields are now listed correctly makes pretty hard to reproduce the problem, but it will still occur if the instance creation or server-side validation fails. The problem seems to be with the `spec.parameters.service.fqdn` field, which the browser *displays* with its previously entered value, but on form submission, the browser *sends* a `"["`, which the server correctly rejects – and then, of course on the second page render with errors, the previous user input is missing, as it never made its way back to the server.
rixx added 1 commit 2025-09-11 12:58:35 +00:00
Fix JSON re-parsing in re-rendered invalid form
All checks were successful
Tests / test (push) Successful in 25s
1a2a75880d
Author
Member

I think I have caught the bug – will require some hard reloads to make sure the new JavaScript is used. I may have gone a bit overboard in defending against it cropping up again, but better safe than sorry. Could you test the fix to see if it works for you aswell, @tobru ?

I *think* I have caught the bug – will require some hard reloads to make sure the new JavaScript is used. I may have gone a bit overboard in defending against it cropping up again, but better safe than sorry. Could you test the fix to see if it works for you aswell, @tobru ?
tobru merged commit 9283c38eaa into main 2025-09-12 07:21:30 +00:00
tobru deleted branch 164-keep-values-on-error 2025-09-12 07:21:30 +00:00
Owner

It looks much better now!

It looks much better now!
Sign in to join this conversation.
No description provided.