[Fix] 500 error by enforcing valid UUID patterns in admin URLs #682
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 #682 .
Description of Changes
This PR fixes a 500 Internal Server Error caused by an incorrect NoReverseMatch when certain admin URLs are accessed. The issue happened because the URL pattern was too loose, allowing invalid UUID formats.
What’s changed?
- Updated the regex to allow only valid UUIDs.
- Added a check in admin.py to ensure UUIDs follow the correct format.
- Updated url.py accordingly.
- Kept support for both standard UUIDs (4290a79a-e740-4abf-b49e-9d5789b580f6) and hex format (4290a79ae7404abfb49e9d5789b580f6).
- Maintained backward compatibility by keeping re_path where needed.
Hi @Unnati-Gupta24 Can you pleaae add a test case for the change also?
Ok thanks understood... Writing test cases for this
I added a test case in admin.py, but the build is failing. I'm checking what might be causing this error. There was an ELOF error in openwisp_controller/config/tests/utils.py, but it has been fixed. Reformatted the files using openwisp-qa-format. But the building is currently failing. I'm working on that..
@Unnati-Gupta24 ping!