From 651179a6428ff5d86020e139fadb2707a764ce2b Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Wed, 3 Dec 2025 13:39:10 +0800 Subject: [PATCH] refactor(config): add detailed logging for legacy configuration migration --- internal/config/config.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 8155231f..2681d049 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -376,9 +376,15 @@ func LoadConfigOptional(configFile string, optional bool) (*Config, error) { // Normalize OAuth provider model exclusion map. cfg.OAuthExcludedModels = NormalizeOAuthExcludedModels(cfg.OAuthExcludedModels) - if cfg.legacyMigrationPending && !optional && configFile != "" { - if err := SaveConfigPreserveComments(configFile, &cfg); err != nil { - return nil, fmt.Errorf("failed to persist migrated legacy config: %w", err) + if cfg.legacyMigrationPending { + fmt.Println("Detected legacy configuration keys, attempting to persist the normalized config...") + if !optional && configFile != "" { + if err := SaveConfigPreserveComments(configFile, &cfg); err != nil { + return nil, fmt.Errorf("failed to persist migrated legacy config: %w", err) + } + fmt.Println("Legacy configuration normalized and persisted.") + } else { + fmt.Println("Legacy configuration normalized in memory; persistence skipped.") } }