Skip to content

Commit 960a7c1

Browse files
Ilanlidoclaude
andcommitted
CM-62984: log file paths via %s + dict (codebase convention)
`extra={'path': ...}` doesn't render under the default Python formatter that cycode-cli uses; the positional `'msg, %s', {'path': ...}` form already used in zip_documents / file_excluder / commit_range_documents does. Migrates the AI-guardrails IDE loaders (Cursor, Claude Code, Codex) and the shared plugin JSON loader to match. Also adds path context to a couple of exception logs that previously discarded it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2a42a9f commit 960a7c1

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

cycode/cli/apps/ai_guardrails/ides/_plugin_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def load_plugin_json(path: Path) -> Optional[dict]:
2222
try:
2323
return json.loads(path.read_text(encoding='utf-8'))
2424
except Exception as e:
25-
logger.debug('Failed to load plugin file', extra={'path': str(path)}, exc_info=e)
25+
logger.debug('Failed to load plugin file, %s', {'path': str(path)}, exc_info=e)
2626
return None
2727

2828

cycode/cli/apps/ai_guardrails/ides/claude_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def load_claude_config(config_path: Optional[Path] = None) -> Optional[dict]:
128128
"""Load and parse `~/.claude.json`. Returns None if missing/invalid."""
129129
path = config_path or _CLAUDE_CONFIG_PATH
130130
if not path.exists():
131-
logger.debug('Claude config file not found', extra={'path': str(path)})
131+
logger.debug('Claude config file not found, %s', {'path': str(path)})
132132
return None
133133
try:
134134
return json.loads(path.read_text(encoding='utf-8'))
@@ -151,7 +151,7 @@ def load_claude_settings(settings_path: Optional[Path] = None) -> Optional[dict]
151151
"""Load and parse `~/.claude/settings.json`. Returns None if missing/invalid."""
152152
path = settings_path or _CLAUDE_SETTINGS_PATH
153153
if not path.exists():
154-
logger.debug('Claude settings file not found', extra={'path': str(path)})
154+
logger.debug('Claude settings file not found, %s', {'path': str(path)})
155155
return None
156156
try:
157157
return json.loads(path.read_text(encoding='utf-8'))

cycode/cli/apps/ai_guardrails/ides/codex.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def _load_codex_config(config_path: Optional[Path] = None) -> Optional[dict]:
5959
"""Load and parse Codex's ``config.toml``. Returns None on missing/invalid."""
6060
path = config_path or (_codex_home() / _CONFIG_TOML_NAME)
6161
if not path.exists():
62-
logger.debug('Codex config file not found', extra={'path': str(path)})
62+
logger.debug('Codex config file not found, %s', {'path': str(path)})
6363
return None
6464
try:
6565
with path.open('rb') as f:
6666
return tomllib.load(f)
6767
except Exception as e:
68-
logger.debug('Failed to load Codex config file', exc_info=e)
68+
logger.debug('Failed to load Codex config file, %s', {'path': str(path)}, exc_info=e)
6969
return None
7070

7171

@@ -78,12 +78,12 @@ def _email_from_auth(auth_path: Optional[Path] = None) -> Optional[str]:
7878
"""
7979
path = auth_path or (_codex_home() / _AUTH_JSON_NAME)
8080
if not path.exists():
81-
logger.debug('Codex auth file not found', extra={'path': str(path)})
81+
logger.debug('Codex auth file not found, %s', {'path': str(path)})
8282
return None
8383
try:
8484
auth = json.loads(path.read_text(encoding='utf-8'))
8585
except (OSError, json.JSONDecodeError) as e:
86-
logger.debug('Failed to load Codex auth file', exc_info=e)
86+
logger.debug('Failed to load Codex auth file, %s', {'path': str(path)}, exc_info=e)
8787
return None
8888

8989
token = (auth.get('tokens') or {}).get('id_token')
@@ -162,7 +162,7 @@ def _enable_codex_hooks_feature(scope: str, repo_path: Optional[Path] = None) ->
162162
with config_path.open('rb') as f:
163163
config = tomllib.load(f)
164164
except Exception as e:
165-
logger.error('Failed to parse Codex config.toml', exc_info=e)
165+
logger.error('Failed to parse Codex config.toml, %s', {'path': str(config_path)}, exc_info=e)
166166
return False, f'Failed to parse existing Codex config at {config_path}'
167167

168168
features = config.get('features')
@@ -177,7 +177,7 @@ def _enable_codex_hooks_feature(scope: str, repo_path: Optional[Path] = None) ->
177177
tomli_w.dump(config, f)
178178
return True, f'Enabled hooks feature in {config_path}'
179179
except Exception as e:
180-
logger.error('Failed to write Codex config.toml', exc_info=e)
180+
logger.error('Failed to write Codex config.toml, %s', {'path': str(config_path)}, exc_info=e)
181181
return False, f'Failed to write Codex config at {config_path}'
182182

183183

cycode/cli/apps/ai_guardrails/ides/cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _load_cursor_mcp_config(config_path: Optional[Path] = None) -> Optional[dict
4343
"""Load and parse `~/.cursor/mcp.json`. Returns None if missing/invalid."""
4444
path = config_path or (Path.home() / '.cursor' / _MCP_CONFIG_FILENAME)
4545
if not path.exists():
46-
logger.debug('Cursor MCP config file not found', extra={'path': str(path)})
46+
logger.debug('Cursor MCP config file not found, %s', {'path': str(path)})
4747
return None
4848
try:
4949
return json.loads(path.read_text(encoding='utf-8'))

0 commit comments

Comments
 (0)