Commit Graph

2 Commits

  • chore: apply cargo fmt before release
    - Format code in app_config.rs to comply with rustfmt rules
    - Remove extra blank line in config.rs
    - Format test code in app_config_load.rs for consistency
  • refactor(config): remove v1 auto-migration and improve error handling
    BREAKING CHANGE: Runtime auto-migration from v1 to v2 config format has been removed.
    
    Changes:
    - Remove automatic v1→v2 migration logic from MultiAppConfig::load()
    - Improve v1 detection using structural analysis (checks for 'apps' key absence)
    - Return clear error with migration instructions when v1 config is detected
    - Add comprehensive tests for config loading edge cases
    - Fix false positive detection when v1 config contains 'version' or 'mcp' fields
    
    Migration path for users:
    1. Install v3.2.x to perform one-time auto-migration, OR
    2. Manually edit ~/.cc-switch/config.json to v2 format
    
    Rationale:
    - Separates concerns: load() should be read-only, not perform side effects
    - Fail-fast principle: unsupported formats should error immediately
    - Simplifies code maintenance by removing migration logic from hot path
    
    Tests added:
    - load_v1_config_returns_error_and_does_not_write
    - load_v1_with_extra_version_still_treated_as_v1
    - load_invalid_json_returns_parse_error_and_does_not_write
    - load_valid_v2_config_succeeds