Skip to content

Commit 9606842

Browse files
dc-larsenclaude
andcommitted
Add log statement indicating config source
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 <noreply@anthropic.com>
1 parent a229781 commit 9606842

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

socket_basics/core/config.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,19 @@ def __init__(self, config_dict: Dict[str, Any] | None = None, json_config_path:
4343
self._config = merge_json_and_env_config()
4444

4545
self._config = self._config
46-
47-
# DEBUG: Log final configuration values
46+
47+
# Log where the configuration is being loaded from
4848
logger = logging.getLogger(__name__)
49+
config_source = self._config.get('_config_source', 'environment')
50+
source_descriptions = {
51+
'api': 'Socket dashboard (API)',
52+
'json_file': 'JSON config file (--config)',
53+
'environment': 'environment variables',
54+
}
55+
source_desc = source_descriptions.get(config_source, config_source)
56+
logger.info(f"Configuration loaded from: {source_desc}")
57+
58+
# DEBUG: Log final configuration values
4959
logger.debug("Final Config object created with key values:")
5060
logger.debug(f" javascript_sast_enabled: {self._config.get('javascript_sast_enabled')}")
5161
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]:
9921002

9931003
def merge_json_and_env_config(json_config: Dict[str, Any] | None = None) -> Dict[str, Any]:
9941004
"""Merge JSON configuration with environment variables
995-
1005+
9961006
Priority order (highest to lowest):
9971007
1. CLI options (handled separately via argparse, highest priority)
9981008
2. Socket Basics API config / JSON config (dashboard settings)
9991009
3. Environment variables from action.yml (lowest priority - defaults)
1000-
1010+
10011011
Args:
10021012
json_config: Optional dictionary from JSON config file
1003-
1013+
10041014
Returns:
10051015
Merged configuration dictionary
10061016
"""
10071017
# Start with environment defaults (lowest priority)
10081018
config = load_config_from_env()
1009-
1019+
# Default source is environment variables
1020+
config['_config_source'] = 'environment'
1021+
10101022
# Override with Socket Basics API config if no explicit JSON config provided
10111023
# API config takes precedence over environment defaults
10121024
if not json_config:
@@ -1027,6 +1039,7 @@ def merge_json_and_env_config(json_config: Dict[str, Any] | None = None) -> Dict
10271039
continue
10281040
filtered_config[k] = v
10291041
config.update(filtered_config)
1042+
config['_config_source'] = 'api'
10301043
logging.getLogger(__name__).info("Loaded Socket Basics API configuration (overrides environment defaults)")
10311044
else:
10321045
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
10451058
continue
10461059
filtered_json[k] = v
10471060
config.update(filtered_json)
1061+
config['_config_source'] = 'json_file'
10481062
logging.getLogger(__name__).info("Loaded JSON configuration (overrides environment defaults)")
10491063

10501064
# Note: CLI arguments are handled separately and take highest priority

0 commit comments

Comments
 (0)