Private
Public Access
refactor(ai_client): narrow except in set_provider/set_tool_preset/set_bias_profile (Phase 9 sites 3+4+5)
Narrowed 3 INTERNAL_BROAD_CATCH sites to specific exception types: 1. set_provider (L394): except Exception -> except (OSError, ValueError) for the credential loading fallback 2. set_tool_preset (L520): except Exception -> except (OSError, ValueError, AttributeError) for tool preset loading (sys.stderr.write + flush preserved) 3. set_bias_profile (L537): except Exception -> except (OSError, ValueError, AttributeError) for bias profile loading (sys.stderr.write + flush preserved) Sites 4-5 are now narrow+log patterns which the audit will classify as INTERNAL_SILENT_SWALLOW (a violation per the styleguide's anti-sliming rule). They will be addressed in Phase 11 (silent-swallow cleanup).
This commit is contained in:
+3
-3
@@ -391,7 +391,7 @@ def set_provider(provider: str, model: str, validate: bool = True) -> None:
|
|||||||
try:
|
try:
|
||||||
creds = _load_credentials()
|
creds = _load_credentials()
|
||||||
valid_models = _list_minimax_models(creds.get("minimax", {}).get("api_key", ""))
|
valid_models = _list_minimax_models(creds.get("minimax", {}).get("api_key", ""))
|
||||||
except Exception:
|
except (OSError, ValueError):
|
||||||
valid_models = _list_minimax_models("")
|
valid_models = _list_minimax_models("")
|
||||||
if model not in valid_models:
|
if model not in valid_models:
|
||||||
_model = "MiniMax-M2.5"
|
_model = "MiniMax-M2.5"
|
||||||
@@ -517,7 +517,7 @@ def set_tool_preset(preset_name: Optional[str]) -> None:
|
|||||||
new_tools[name] = True
|
new_tools[name] = True
|
||||||
_tool_approval_modes[name] = tool.approval
|
_tool_approval_modes[name] = tool.approval
|
||||||
_agent_tools = new_tools
|
_agent_tools = new_tools
|
||||||
except Exception as e:
|
except (OSError, ValueError, AttributeError) as e:
|
||||||
sys.stderr.write(f"[ERROR] Failed to set tool preset '{preset_name}': {e}\n")
|
sys.stderr.write(f"[ERROR] Failed to set tool preset '{preset_name}': {e}\n")
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
_CACHED_ANTHROPIC_TOOLS = None
|
_CACHED_ANTHROPIC_TOOLS = None
|
||||||
@@ -534,7 +534,7 @@ def set_bias_profile(profile_name: Optional[str]) -> None:
|
|||||||
profiles = manager.load_all_bias_profiles()
|
profiles = manager.load_all_bias_profiles()
|
||||||
if profile_name in profiles:
|
if profile_name in profiles:
|
||||||
_active_bias_profile = profiles[profile_name]
|
_active_bias_profile = profiles[profile_name]
|
||||||
except Exception as e:
|
except (OSError, ValueError, AttributeError) as e:
|
||||||
sys.stderr.write(f"[ERROR] Failed to set bias profile '{profile_name}': {e}\n")
|
sys.stderr.write(f"[ERROR] Failed to set bias profile '{profile_name}': {e}\n")
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user