Closed codingisacopingstrategy closed 5 years ago
To echo this rather old issue: If I use condition_dict
to show some wizard steps only some of the time, and those conditions change unexpectedly, removing that step from the logic before the user submits their (already loaded page) – django-formtools leads to an exception.
File "/home/pretalx_prod/.local/lib/python3.7/site-packages/formtools/wizard/views.py" in next
81. return self._wizard.get_next_step()
File "/home/pretalx_prod/.local/lib/python3.7/site-packages/formtools/wizard/views.py" in get_next_step
520. key = keys.index(step) + 1
ValueError: 'broken_step' is not in list```
(For reference, this is the offending line: https://github.com/django/django-formtools/blob/master/formtools/wizard/views.py#L529). Checking that the step exists in the list seems a prudent precaution.
Hello,
I tested in 1.6 but it looks like this behaviour is still the same: https://github.com/django/django-formtools/blob/master/formtools/wizard/views.py#L408
A user has been tampering with the
current_step
part of a POST request that is part of a the Django Form Wizard. The current step should be something like ‘request-sim’ but the user changes it to ‘-’. Formtools does not seems to check whether the step actually exists. So it raises a KeyError when trying to access it.Could this error be handled more gracefully? Catch the
KeyError
and respond with a Bad request if thestep
has been tampered with?Thanks a bunch for Django+formtools, Cheers!
This is the exception:
This is the data from the post request: