From 81984a7ebd7f7cebea471d1a4c98a8eaf8624874 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 3 Sep 2026 09:48:45 -0700 Subject: [PATCH] =?UTF-8?q?review-fix(suppress-audit):=20bedrock=5Fadapter?= =?UTF-8?q?/run=5Fturn=5Frunner/self=5Frepo=5Fguard=20=E2=80=94=20restore?= =?UTF-8?q?=20BASE=20exception=20semantics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/bedrock_adapter.py | 3 ++- gateway/run_turn_runner.py | 7 +++++-- tools/self_repo_guard.py | 14 ++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/agent/bedrock_adapter.py b/agent/bedrock_adapter.py index 26f0152516..a24513b026 100644 --- a/agent/bedrock_adapter.py +++ b/agent/bedrock_adapter.py @@ -205,7 +205,8 @@ def _stale_error_types() -> tuple: ("botocore.exceptions", ("ConnectionError", "HTTPClientError")), ("urllib3.exceptions", ("ProtocolError", "NewConnectionError", "ConnectionError")), ): - with suppress(ImportError): # pragma: no cover — both present with boto3 + # AttributeError too: ``from mod import Name`` raised ImportError for a missing name. + with suppress(ImportError, AttributeError): # pragma: no cover — both present with boto3 types += [getattr(importlib.import_module(module), name) for name in names] return tuple(types) diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.py index a7c0696cca..6735b49557 100644 --- a/gateway/run_turn_runner.py +++ b/gateway/run_turn_runner.py @@ -76,8 +76,11 @@ class TurnRunner: ctx._cleanup_msg_ids.append(str(result.message_id)) def _track_future_cleanup_id(self, fut) -> None: - with suppress(Exception): - self._track_progress_result(fut.result()) + try: + res = fut.result() + except Exception: + return + self._track_progress_result(res) # ── progress_callback (agent thread → progress queue) ─────────────────────────────────── diff --git a/tools/self_repo_guard.py b/tools/self_repo_guard.py index a97bb2ffb0..35ab063966 100644 --- a/tools/self_repo_guard.py +++ b/tools/self_repo_guard.py @@ -70,10 +70,11 @@ class _ShellContext: # one `(` / `$(` / backtick nesting level and its live quo def get_running_source_root() -> Path | None: """The source checkout backing this process, if there is one.""" - with contextlib.suppress(OSError, RuntimeError): + try: root = Path(__file__).resolve().parent.parent - return root if (root / ".git").exists() else None - return None + except (OSError, RuntimeError): + return None + return root if (root / ".git").exists() else None def _resolve(path_str: str, base: Path) -> Path: @@ -373,10 +374,11 @@ def _inspect_git( return None if alias.startswith("!"): # shell alias: scan it as a command return _find_mutation(alias[1:], target, root, depth + 1) - with contextlib.suppress(ValueError): + try: alias_args = shlex.split(alias, posix=True) - return _inspect_git(executable, [*alias_args, *sub_args], target, {}, root, depth + 1) - return None + except ValueError: + return None + return _inspect_git(executable, [*alias_args, *sub_args], target, {}, root, depth + 1) def _inspect_github_cli(