Skip to content

udm-wan-monitor: fix runtime imports in detail and test routes#11

Merged
itsDNNS merged 2 commits into
itsDNNS:mainfrom
sparkleHazard:fix/udm-wan-monitor-relative-imports
Jul 27, 2026
Merged

udm-wan-monitor: fix runtime imports in detail and test routes#11
itsDNNS merged 2 commits into
itsDNNS:mainfrom
sparkleHazard:fix/udm-wan-monitor-relative-imports

Conversation

@sparkleHazard

@sparkleHazard sparkleHazard commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

DOCSight loads community routes and collectors under different synthetic module names. Relative imports from routes.py therefore fail at request time in the configuration-dependent routes.

  • Reuse the collector module loaded by DOCSight instead of using relative imports
  • Derive the collector key from the actual installed directory
  • Keep direct sibling loading as a guarded fallback and clean up failed imports
  • Add dependency-free runtime-loader regression coverage for catalog and custom directory names
  • Bump the module to 3.1.4

User impact

GET /api/udm-wan/detail and POST /api/udm-wan/test no longer return HTTP 500 because of ModuleNotFoundError. The cached /api/udm-wan/status route was not affected.

Verification

  • python3 -m unittest discover -s tests -q (8 tests)
  • python3 scripts/validate_registry.py
  • python3 -m py_compile udm-wan-monitor/routes.py udm-wan-monitor/collector.py
  • DOCSight core manifest contract
  • DOCSight core route and collector loader integration

sparkleHazard and others added 2 commits July 26, 2026 22:12
DOCSight loads a community module's routes.py via spec_from_file_location as a synthetic top-level module (community_modules.<dir>.routes) without registering parent packages, so every 'from .collector import ...' inside the route handlers raises ModuleNotFoundError at request time. This broke POST /api/udm-wan/test (Test connection button) and GET /api/udm-wan/status with a 500 for all users.

Replace the relative imports with a _collector_mod() helper that reuses the collector module DOCSight already imported (app.modules.<dir>.collector) or loads the sibling collector.py directly. Bump version to 3.1.4.
@itsDNNS itsDNNS changed the title udm-wan-monitor: fix ModuleNotFoundError in all route handlers (relative imports) udm-wan-monitor: fix runtime imports in detail and test routes Jul 27, 2026
@itsDNNS
itsDNNS merged commit 36b4d46 into itsDNNS:main Jul 27, 2026
1 check passed
@itsDNNS

itsDNNS commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Thanks for the submission and for tracking down the runtime import issue in the UDM WAN Monitor. The fix is now merged, with regression coverage for the loader path. Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants