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

Fix MultiValueDictKeyError on empty device form submission 1057

Open Srinath0916 opened this issue 3 weeks ago • 10 comments

Checklist

  • [x] I have read the OpenWISP Contributing Guidelines.
  • [x] I have manually tested the changes proposed in this pull request.
  • [x] I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • [ ] I have updated the documentation.

Reference to Existing Issue

Closes #1057

Description of Changes

Fixed the MultiValueDictKeyError that happened when you click "Add another Configuration" on a new device and hit save without filling anything in.

The problem was in the ConfigForm.get_temp_model_instance() method - it was trying to access organization, name, and mac_address from the form data without checking if they exist first. Changed it to use .get() so it handles empty fields properly and shows validation errors instead of crashing.

Added a test case to verify the fix works.

Screenshot

See issue #1057 for the error screenshot. After the fix, the form now shows proper validation errors instead of crashing.

Srinath0916 avatar Dec 08 '25 19:12 Srinath0916

Hey @DragnEmperor , really sorry for the inconvenience, I had to fix the commit message format to match the project guidelines (added the [fix] prefix). Could you approve the workflow one more time? should be good to go now.

Srinath0916 avatar Dec 09 '25 16:12 Srinath0916

Coverage Status

coverage: 98.608% (+0.001%) from 98.607% when pulling 81f0780b62be472630e797fe09d5ffc5055b390f on Srinath0916:fix-multivaluedictkeyerror-1057 into aa2561fc452cd91a96b416bfeb565bc7a029fb38 on openwisp:master.

coveralls avatar Dec 10 '25 11:12 coveralls

Hi @pandafy , @DragnEmperor , all checks are passing now, This PR is ready for review.

Srinath0916 avatar Dec 10 '25 11:12 Srinath0916

Hi @pandafy , @DragnEmperor , all checks are passing now, This PR is ready for review.

Hi @Srinath0916 , I would suggest to have a look once again through all the changes done to ensure any unrelated changes are not there. I see some changes in workflow yaml file.

DragnEmperor avatar Dec 10 '25 12:12 DragnEmperor

Thanks @DragnEmperor ! I've reviewed all changes in this PR,

The MultiValueDictKeyError fix includes: - config/admin.py (the main fix) - config/base/config.py (related changes) - config/tests/test_admin.py (test for the fix)

The workflow yaml changes include: - Geckodriver logging removal (as you said) and Python 3.9 related changes from updating with master (PR #1174)

Should I clean up the workflow file to keep only the geckodriver removal you asked for and remove the Python 3.9 changes? I want to make sure the tests still pass."

Srinath0916 avatar Dec 10 '25 14:12 Srinath0916

Thanks @DragnEmperor ! I've reviewed all changes in this PR,

The MultiValueDictKeyError fix includes: - config/admin.py (the main fix) - config/base/config.py (related changes) - config/tests/test_admin.py (test for the fix)

The workflow yaml changes include: - Geckodriver logging removal (as you said) and Python 3.9 related changes from updating with master (PR #1174)

Should I clean up the workflow file to keep only the geckodriver removal you asked for and remove the Python 3.9 changes? I want to make sure the tests still pass."

@Srinath0916 I meant to keep the ci.yml as it is, no changes at all, currently I see there is some removal of code

DragnEmperor avatar Dec 10 '25 16:12 DragnEmperor

Thanks @DragnEmperor ! I've reverted ci.yml to match master exactly. Now the PR contains only the MultiValueDictKeyError fix files with no workflow changes. Ready for review!

Srinath0916 avatar Dec 10 '25 16:12 Srinath0916

LGTM

DragnEmperor avatar Dec 10 '25 16:12 DragnEmperor

Thank you @DragnEmperor , Really appreciate your patience and detailed feedback throughout this process.

Srinath0916 avatar Dec 10 '25 17:12 Srinath0916

Hi @pandafy , This PR has been approved, and all checks are passing. Could you help merge it when you get a chance? Thanks.

Srinath0916 avatar Dec 11 '25 10:12 Srinath0916