fix: pysnmp 7.x transport factory + bare-repo git init crash - #201
Merged
Conversation
…SON, no-valid) (88% -> 91%)
…snmp trap, baseline enrich (89% -> 96%)
…crash - vendor_registry: use await UdpTransportTarget.create((host, port), timeout=, retries=) instead of the removed pysnmp 4.x positional constructor (SNMP auto-detection was broken under installed pysnmp 7.1.22: 'multiple values for argument timeout'). Falls back to the 4.x constructor when .create is absent. - git_history: init_git_repo(bare=True) no longer tries to seed a .gitkeep commit on a repo with no working tree (GitPython raised on index.add). Bare repos now initialize cleanly; the working_tree_dir is None guards in save/rollback are reachable.
test_snmp_detection_with_mock previously passed only because the broken pysnmp 4.x transport constructor raised and the broad except fell back to cisco_ios. After the pysnmp 7.x fix the mocked get_cmd actually runs against the IOS-XE sysDescr, so the expected vendor is cisco_xe. Mock UdpTransportTarget to keep the test hermetic (no real network call).
# Conflicts: # tests/test_vendor_registry_snmp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two real bugs discovered during the coverage push (both were masking or breaking functionality on the installed dependency versions):
vendor_registry.detect_vendor_snmp— pysnmp 7.x replaced theUdpTransportTarget((host, port), timeout=, retries=)positional constructor with an awaitable factoryUdpTransportTarget.create((host, port), timeout=, retries=). The old call raisedTypeError: AbstractTransportTarget.__init__() got multiple values for argument 'timeout', so SNMP auto-detection was completely broken under the installed pysnmp 7.1.22. Fixed to useawait ...create(...)with a graceful fallback to the 4.x constructor when.createis absent.git_history.init_git_repo(bare=True)— tried to seed a.gitkeepcommit on a bare repo (no working tree), which GitPython rejected. Bare repos now initialize cleanly; the previously-deadworking_tree_dir is Noneguards insave_config_snapshot/rollback_configare now reachable.Test plan
test_live_pysnmp7_create_does_not_crash(vendor_registry) exercising the real pysnmp 7.x.create()API against a non-routable address.test_git_history.py:init_git_repo(bare=True)succeeds, andsave_config_snapshot/rollback_configcorrectly raiseGitHistoryErroron a bare repo.test_vendors_expanded.test_snmp_detection_with_mockhermetic (mockUdpTransportTarget) — it had only been "passing" because the broken constructor raised and the broadexceptfell back. Corrected expected vendor tocisco_xe(the fixture is IOS-XE).Verification
Full gate green: 736 passed, coverage 92.47% (up from 90.38%), ruff + strict mypy (src) + bandit all clean.
🤖 Generated with Hermes Agent