[fix] Close telnet connection properly in convert_called_station_id#750
[fix] Close telnet connection properly in convert_called_station_id#750omlahore wants to merge 1 commit into
Conversation
…penwisp#727 Exscript's telnetlib.Telnet does not implement the context manager protocol, so the `with Telnet(...)` in _get_raw_management_info raised a TypeError that was swallowed by the broad except in _get_openvpn_routing_info. The command exited silently without converting any called_station_id. Open the connection explicitly and close it in a finally block, and add a regression test that drives the real telnet path. Fixes openwisp#727 Signed-off-by: Om <omlahore47@gmail.com>
|
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 (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (13)
🧰 Additional context used📓 Path-based instructions (1)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🔇 Additional comments (2)
📝 WalkthroughWalkthroughThe Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 8✅ Passed checks (8 passed)
✨ 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 |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Nice, well-scoped fix. Replacing the Files Reviewed (2 files)
Reviewed by claude-opus-4.8 · Input: 26 · Output: 3.3K · Cached: 583.5K |
|
The CI failures here look unrelated to this change. Every job fails at the QA This PR only touches Would you prefer the |
Checklist
Explanation
Exscript.protocols.telnetlib.Telnetis a re-implementation of the standard library'stelnetliband does not implement the context manager protocol (no__enter__/__exit__). As a result, thewith telnetlib.Telnet(...) as tnin_get_raw_management_inforaised aTypeError, which was silently swallowed by the broadexcept Exceptionin_get_openvpn_routing_info. Theconvert_called_station_idcommand therefore exited without converting anycalled_station_id, and no error was surfaced.This opens the connection explicitly and closes it in a
finallyblock instead of using a context manager.A regression test drives the real telnet path (patching
telnetlib.Telnetwith a fake that lacks the context manager protocol, mirroring Exscript) and asserts that thecalled_station_idis converted and the connection is closed. Without the fix, the conversion silently does not happen.Fixes #727