Skip to content

Address PR #252 review findings: error handling, tests, type design #256

@neuromechanist

Description

@neuromechanist

Context

PR #252 (Release v0.8.0: develop -> main) was reviewed with 5 specialized agents. The review found legitimate issues that should be fixed before merging to main.

Important Issues (fix before merge)

Error Handling

  • 1. Missing CorruptMirrorError/ValueError handling in 4 mirror endpoints (mirrors.py:164,205,225,277)
  • 2. Cost check fails open for unknown models (community.py:621-628)
  • 3. Missing OSError handling in create_mirror_endpoint (mirrors.py:129-137)
  • 4. One stuck mirror blocks cleanup of all others (mirror.py:409-417)

Code Quality

  • 5. asyncio.get_event_loop() deprecated; use get_running_loop() (mirrors.py:249)
  • 6. Missing field_validator on RefreshMirrorRequest.community_ids (mirrors.py:89-94)
  • 7. Broad except Exception in _cleanup_mirrors (scheduler.py:302-308)

Test Gaps

  • 8. No HTTP-level tests for mirror routing middleware
  • 9. No HTTP-level tests for mirrors API router
  • 10. No test for active_mirror_context context manager
  • 11. No test for MirrorInfo.__post_init__ validation
  • 12. No test for run_sync_now with invalid sync_type
  • 13. No test for TTL clamping in create_mirror

Comment Fixes

  • 14. Fix enable_caching docstring ("enabled" -> "requested")
  • 15. Fix asyncio.to_thread comment (code uses run_in_executor)
  • 16. Fix get_model docstring example (claude-3-5-sonnet -> claude-3.5-sonnet)

Type Design Improvements

  • 17. Make MirrorInfo a frozen dataclass
  • 18. Move is_safe_identifier to shared utility
  • 19. Add non-negativity check to ModelRate.__new__
  • 20. Expand SecureFormatter key patterns for other providers

Origin

PR #252 review findings from code-reviewer, silent-failure-hunter, test-analyzer, comment-analyzer, and type-design-analyzer agents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1: Critical, fix as soon as possiblebugSomething isn't workingtestingTesting and quality assurance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions