From 9606842857adaa00cfeb22935a6fbef035fa3c55 Mon Sep 17 00:00:00 2001 From: David Larsen Date: Tue, 6 Jan 2026 13:32:25 -0800 Subject: [PATCH] Add log statement indicating config source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an INFO-level log message that tells users where the configuration is being loaded from. The three possible sources are: 1. Socket dashboard (API) - when using enterprise plan with dashboard config 2. JSON config file (--config) - when a config file is specified via CLI 3. Environment variables - the default when no other source is available This helps users debug configuration issues by making it clear which source took precedence. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- socket_basics/core/config.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/socket_basics/core/config.py b/socket_basics/core/config.py index 55512cf..544e464 100644 --- a/socket_basics/core/config.py +++ b/socket_basics/core/config.py @@ -43,9 +43,19 @@ def __init__(self, config_dict: Dict[str, Any] | None = None, json_config_path: self._config = merge_json_and_env_config() self._config = self._config - - # DEBUG: Log final configuration values + + # Log where the configuration is being loaded from logger = logging.getLogger(__name__) + config_source = self._config.get('_config_source', 'environment') + source_descriptions = { + 'api': 'Socket dashboard (API)', + 'json_file': 'JSON config file (--config)', + 'environment': 'environment variables', + } + source_desc = source_descriptions.get(config_source, config_source) + logger.info(f"Configuration loaded from: {source_desc}") + + # DEBUG: Log final configuration values logger.debug("Final Config object created with key values:") logger.debug(f" javascript_sast_enabled: {self._config.get('javascript_sast_enabled')}") logger.debug(f" socket_tier_1_enabled: {self._config.get('socket_tier_1_enabled')}") @@ -992,21 +1002,23 @@ def normalize_api_config(api_config: Dict[str, Any]) -> Dict[str, Any]: def merge_json_and_env_config(json_config: Dict[str, Any] | None = None) -> Dict[str, Any]: """Merge JSON configuration with environment variables - + Priority order (highest to lowest): 1. CLI options (handled separately via argparse, highest priority) 2. Socket Basics API config / JSON config (dashboard settings) 3. Environment variables from action.yml (lowest priority - defaults) - + Args: json_config: Optional dictionary from JSON config file - + Returns: Merged configuration dictionary """ # Start with environment defaults (lowest priority) config = load_config_from_env() - + # Default source is environment variables + config['_config_source'] = 'environment' + # Override with Socket Basics API config if no explicit JSON config provided # API config takes precedence over environment defaults if not json_config: @@ -1027,6 +1039,7 @@ def merge_json_and_env_config(json_config: Dict[str, Any] | None = None) -> Dict continue filtered_config[k] = v config.update(filtered_config) + config['_config_source'] = 'api' logging.getLogger(__name__).info("Loaded Socket Basics API configuration (overrides environment defaults)") else: logger.debug(" No Socket Basics API config loaded") @@ -1045,6 +1058,7 @@ def merge_json_and_env_config(json_config: Dict[str, Any] | None = None) -> Dict continue filtered_json[k] = v config.update(filtered_json) + config['_config_source'] = 'json_file' logging.getLogger(__name__).info("Loaded JSON configuration (overrides environment defaults)") # Note: CLI arguments are handled separately and take highest priority