django-formtools icon indicating copy to clipboard operation
django-formtools copied to clipboard

Forms with CookieWizardView fail silently if forms are too large

Open gjlondon opened this issue 9 years ago • 1 comments

I was having a strange bug where I could go all the way through my wizard with no validation errors, but then when hitting the final submit I'd be taken back to an earlier step (now blank) with no validation errors. And looking inside render_revalidation_failure I could see that the form was now unbound.

I eventually figured out that the problem was that cookies have a maximum length (around 4096 bytes) and Django will silently fail to set a cookie if it's too large. One of my forms had several dozen fields (not ideal UX I know) and so CookieStorage.update_response is called, it silently fails to update the cookie. And then when WizardView.render_done tries to revalidate all the data at the end of the wizard, it fails to find any data for the offending large step and thus fails to validate.

This is clearly an edge case and it seems that the main Django project examined the issue of large cookies and decided to do nothing. But this is a very confusing failure when it happens. Adding some kind of validation that the cookie has actually been successfully modified and throwing a clear exception if it hasn't would make this rare problem way easier to debug or avoid.

gjlondon avatar May 15 '15 01:05 gjlondon

:+1: I have the same error and lost several hours with this issue :/

juanpex avatar Apr 03 '16 07:04 juanpex