fix(08): fix infinite recursion in config manager

This commit is contained in:
2026-04-23 14:51:51 +03:00
parent 9afe335384
commit 827dfcdf2f
3 changed files with 12 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import os
import yaml
import logging
from .config_loader import load_config, get_config
from .config_loader import load_config as loader_load_config, get_config as loader_get_config
log = logging.getLogger("ainventory")
@@ -52,8 +52,8 @@ class ConfigManager:
log.info(f"✅ Updated {path} with new values.")
# Reload the global config
load_config()
return get_config()
loader_load_config()
return loader_get_config()
except Exception as e:
log.error(f"❌ Failed to write {path}: {e}")
raise
@@ -103,8 +103,8 @@ class ConfigManager:
log.info(f"✅ Updated {path} with new secrets.")
# Reload the global config
load_config()
return get_config()
loader_load_config()
return loader_get_config()
except Exception as e:
log.error(f"❌ Failed to write {path}: {e}")
raise
@@ -133,17 +133,17 @@ class ConfigManager:
if backend_updates:
ConfigManager.update_config(backend_updates)
return get_config()
return loader_get_config()
@staticmethod
def get_config() -> dict:
"""Return the current global configuration."""
return get_config()
return loader_get_config()
@staticmethod
def get_masked_key(key_name: str):
"""Returns a masked version of a configuration value or env var."""
config = get_config()
config = loader_get_config()
# Try to find in config first
val = None
@@ -183,7 +183,7 @@ def update_config(updates: dict) -> dict:
def get_config() -> dict:
"""Return the current global configuration."""
return ConfigManager.get_config()
return loader_get_config()
def validate_config_file() -> bool:
"""Validate backend.yaml syntax and required fields."""