Skip to content

fix: pysnmp 7.x transport factory + bare-repo git init crash - #201

Merged
Elshayib merged 10 commits into
masterfrom
fix/snmp-git-bugs
Jul 20, 2026
Merged

fix: pysnmp 7.x transport factory + bare-repo git init crash#201
Elshayib merged 10 commits into
masterfrom
fix/snmp-git-bugs

Conversation

@Elshayib

Copy link
Copy Markdown
Owner

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 the UdpTransportTarget((host, port), timeout=, retries=) positional constructor with an awaitable factory UdpTransportTarget.create((host, port), timeout=, retries=). The old call raised TypeError: AbstractTransportTarget.__init__() got multiple values for argument 'timeout', so SNMP auto-detection was completely broken under the installed pysnmp 7.1.22. Fixed to use await ...create(...) with a graceful fallback to the 4.x constructor when .create is absent.
  • git_history.init_git_repo(bare=True) — tried to seed a .gitkeep commit on a bare repo (no working tree), which GitPython rejected. Bare repos now initialize cleanly; the previously-dead working_tree_dir is None guards in save_config_snapshot/rollback_config are now reachable.

Test plan

  • Added test_live_pysnmp7_create_does_not_crash (vendor_registry) exercising the real pysnmp 7.x .create() API against a non-routable address.
  • Added bare-repo coverage in test_git_history.py: init_git_repo(bare=True) succeeds, and save_config_snapshot/rollback_config correctly raise GitHistoryError on a bare repo.
  • Made test_vendors_expanded.test_snmp_detection_with_mock hermetic (mock UdpTransportTarget) — it had only been "passing" because the broken constructor raised and the broad except fell back. Corrected expected vendor to cisco_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

Elshayib added 8 commits July 19, 2026 06:42
…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).
@github-actions github-actions Bot added bug Something isn't working enhancement New feature or request tests labels Jul 20, 2026
@github-actions github-actions Bot added the chore label Jul 20, 2026
# Conflicts:
#	tests/test_vendor_registry_snmp.py
@github-actions github-actions Bot removed the chore label Jul 20, 2026
@Elshayib
Elshayib merged commit 188c99c into master Jul 20, 2026
9 checks passed
@Elshayib
Elshayib deleted the fix/snmp-git-bugs branch July 20, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant