openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

[bug] Uncaught exception: MultiValueDictKeyError at /admin/config/device/add/

Open nemesifier opened this issue 7 months ago • 2 comments

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:

  1. Add a new device
  2. Click on "+ Add another Configuration"
  3. Hit save and continue

Expected behavior A validation error should be shown in the UI, but the uncaugh exception is raised instead.

Screenshots Image

System Information:

  • current dev version (1.2.0a)

nemesifier avatar May 27 '25 13:05 nemesifier

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!

prafullpandey614 avatar Oct 23 '25 04:10 prafullpandey614

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?

Srinath0916 avatar Dec 08 '25 18:12 Srinath0916