Fix: avoid mutating device.name in _get_common_name#1300
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🧰 Additional context used📓 Path-based instructions (5)**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}📄 CodeRabbit inference engine (Custom checks)
Files:
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sql}📄 CodeRabbit inference engine (Custom checks)
Files:
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sh,bash,sql}📄 CodeRabbit inference engine (Custom checks)
Files:
**/*.{py,html}📄 CodeRabbit inference engine (Custom checks)
Files:
**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (3)📚 Learning: 2026-01-15T15:05:49.557ZApplied to files:
📚 Learning: 2026-02-17T19:13:10.088ZApplied to files:
📚 Learning: 2026-01-15T15:07:17.354ZApplied to files:
🔇 Additional comments (2)
📝 WalkthroughWalkthroughAbstractVpnClient._get_common_name() was changed to truncate the device name into a local variable instead of mutating d.name. The local truncated name is used for the Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested labelsenhancement Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Commit Message Format FailureHello @k-sumayya, The CI failed because the commit message does not follow the required format. Please ensure your commit messages adhere to the following structure:
Here is an example of a correctly formatted commit message: |
This fixes an issue where device.name was modified in-place, which could cause unexpected behavior due to Django ORM caching. Fixes openwisp#1300
c392985 to
4510266
Compare
This fixes an issue where device.name was modified in-place, which could cause unexpected behavior due to Django ORM caching. Fixes openwisp#1300
4510266 to
46acb5f
Compare
|
Thank you for the review! Please let me know if anything else is needed from my side. |
nemesifier
left a comment
There was a problem hiding this comment.
Good catch @k-sumayya, this is a correct and worthwhile fix. The old code did d.name = d.name[:end], mutating the in-memory device instance as a side effect of generating a VPN common name. Because that object can be reused and potentially saved later in the same request, this could silently truncate and persist the device's actual name. Switching to a local name variable removes the side effect while keeping identical output.
One thing before merge:
- Please add a regression test asserting that after
_get_common_name()runs,device.nameis unchanged (and that the generated common name is still correct, including the{mac_address}-{name}collapse-to-{mac_address}branch). This is exactly the kind of side-effect bug that silently comes back without a test pinning it.
Correct fix, just add the test and it is ready.
|
Hi @k-sumayya 👋, This is a friendly reminder that this pull request has had no activity for 8 days since changes were requested. We'd love to see this contribution merged! Please take a moment to:
If you're busy or need more time, no worries! Just leave a comment to let us know you're still working on it. Note: within 6 more days, the linked issue will be unassigned to allow other contributors to work on it. Thank you for your contribution! 🙏 |
|
Hi @k-sumayya 👋, This pull request has been marked as stale due to 14 days of inactivity after changes were requested. As a result, any linked issues are being unassigned from you so other contributors can pick them up. However, you can still continue working on this PR! If you push new commits or respond to the review feedback:
If you need more time or have questions about the requested changes, please let us know. We're happy to help! 🤝 |
Dependency Conflict During Package InstallationHello @k-sumayya, There is a dependency conflict between Failure: The CI failed because To Fix: Update the version specifier for |
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3). |
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (2/3). |
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (3/3). |
Test Failures in Selenium TestsHello @k-sumayya, The CI build failed due to a test error in Failure: Location: Fix: Additionally, several other Selenium tests are reported as slow, which is a separate issue that might need attention after the primary failure is resolved. |
|
Added the requested regression test to ensure device.name remains unchanged after _get_common_name() runs. The remaining CI failure appears to be in the unrelated Selenium test TestDevice.test_restoring_deleted_device |
|
Thanks for following up, @k-sumayya! 🙌 The stale status has been removed and the linked issue(s) have been reassigned to you. Looking forward to your updates! |
Fix: Avoid in-place mutation of device.name in _get_common_name
This PR fixes an issue where
_get_common_namewas mutatingdevice.namedirectly, causing unintended side effects due to Django ORM caching.Changes:
device.namenameto safely handle truncationResult:
device.nameunchangedCloses #1296