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

[Fix] 500 error by enforcing valid UUID patterns in admin URLs #682

Open Unnati-Gupta24 opened this issue 10 months ago • 4 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 #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.

Unnati-Gupta24 avatar Feb 12 '25 10:02 Unnati-Gupta24

Hi @Unnati-Gupta24 Can you pleaae add a test case for the change also?

devkapilbansal avatar Feb 24 '25 18:02 devkapilbansal

Ok thanks understood... Writing test cases for this

Unnati-Gupta24 avatar Feb 26 '25 04:02 Unnati-Gupta24

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 avatar Feb 27 '25 13:02 Unnati-Gupta24

@Unnati-Gupta24 ping!

Aryamanz29 avatar Apr 03 '25 07:04 Aryamanz29