[bug] Uncaught exception: MultiValueDictKeyError at /admin/config/device/add/
Describe the bug An uncaught exception is raised if a user submits an empty add device form:
MultiValueDictKeyError at /admin/config/device/add/
Steps To Reproduce Steps to reproduce the behavior:
- Add a new device
- Click on "+ Add another Configuration"
- Hit save and continue
Expected behavior A validation error should be shown in the UI, but the uncaugh exception is raised instead.
Screenshots
System Information:
- current dev version (1.2.0a)
Hi! @nemesifier I’d like to work on this issue.
Understanding of the issue: The MultiValueDictKeyError occurs when submitting an empty “Add Device” form with an additional “Configuration” inline added. This happens because the expected form data key is missing, and the view doesn’t handle it gracefully.
Proposed fix:
Add validation to handle missing form or inline data before accessing keys in the request.
Ensure the admin form shows a proper validation error message instead of raising an exception.
Add a unit test to reproduce and confirm the fix.
Could you please confirm if there are any specific validation patterns or helper utilities preferred in this project before I start working on the fix?
Once confirmed, I’ll open a PR referencing this issue.
Thanks!
Hey @nemesifier, it's been a while since the last update. I've already worked on a fix for this - the issue is in the ConfigForm.get_temp_model_instance() method where it tries to access form data that doesn't exist when fields are empty.
I'm looking to submit a PR with the fix and test case. Can I go ahead?