Fix: Validate current_step on submit#294
Closed
obarahona10 wants to merge 1 commit intojazzband:masterfrom
Closed
Conversation
Inspired by jazzband#224 Thank you @jsma
8047318 to
eb81ebb
Compare
There was a problem hiding this comment.
Pull request overview
Adds validation for the wizard management form’s current_step field to prevent tampered submissions from triggering server errors (aligning with django-formtools PR #224).
Changes:
- Add a wizard test asserting invalid
current_stepsubmissions return HTTP 400. - Extend
ManagementFormto validatecurrent_stepagainst the known wizard steps. - Update wizard views to pass the step list into
ManagementForm.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/wizard/wizardtests/tests.py |
Adds coverage for invalid current_step POST data returning 400. |
formtools/wizard/views.py |
Passes the wizard step list into ManagementForm during POST handling and context rendering. |
formtools/wizard/forms.py |
Implements current_step validation in ManagementForm. |
Comments suppressed due to low confidence (2)
formtools/wizard/forms.py:20
- The
ValidationErrormessage here is user-facing if someone rendersManagementFormerrors directly, but it's currently not marked for translation. Use Django's i18n utilities (e.g.,gettext_lazy) for the error message to match the rest of the wizard’s translated strings.
raise ValidationError("Invalid step name.")
tests/wizard/wizardtests/tests.py:77
- Test naming is inconsistent with the surrounding suite (nearby tests use the
test_form_post_...prefix, e.g.test_form_post_mgmt_data_missing). Renaming this to follow the same pattern will make the suite easier to scan and keep reports grouped consistently.
def test_invalid_current_step_data(self):
wizard_step_data = self.wizard_step_data[0].copy()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inspired by #224