Skip to content

fix(templates): add input validation, callable checks, and cycle tracing in _runtime_dependency_order - #1

Open
Vishaaallll wants to merge 2 commits into
mainfrom
fix/templates-dependency-type-safety
Open

Vishaaallll wants to merge 2 commits into
mainfrom
fix/templates-dependency-type-safety

Conversation

@Vishaaallll

Copy link
Copy Markdown
Owner

Summary

Adds strict input type validation and defensive error handling for service dependency resolution in _runtime_dependency_order() in ods/extensions/services/dashboard-api/routers/templates.py:

  • Validates that service_id is a non-empty string.
  • Verifies read_direct_deps parameter is callable and returns iterable collections (list, tuple, set).
  • Skips non-string or whitespace-only dependency entries during iteration.
  • Encloses recursive dependency traversal in a try...finally block to guarantee _visiting set cleanup even when exceptions occur.
  • Enriches circular dependency error detail by formatting the full cycle path (e.g., service_a -> service_b -> service_a).

Why It Is Useful

  • Prevents State Leakage & Cascading Failures: Standardizes recursion cleanup in _visiting state so subsequent requests do not fail due to lingering stack frames when errors occur during dependency resolution.
  • Hardens API Resilience: Guards against unhandled server exceptions when custom extension manifests contain unexpected schema structures or null dependency elements.
  • Improves Operator Diagnostics: Provides explicit, formatted cycle chains in error responses for faster troubleshooting of template configuration issues.

Verification

  • Ran test suite pytest ods/extensions/services/dashboard-api/tests/test_templates.py -v (31 passed).

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