Skip to content

The agent that grows with you

review-fix(suppress-audit): backup/mcp_oauth/wake_word/run_notifications — restore BASE exception semantics

Teknium2dbfd3b4aabc
diff --git a/gateway/run_notifications.py b/gateway/run_notifications.py
index 7dc18f0366f..1f8be3857e5 100644
--- a/gateway/run_notifications.py
+++ b/gateway/run_notifications.py
@@ -372,7 +372,7 @@ class GatewayNotificationsMixin:
chat_id = pending.get("chat_id")
session_key = pending.get("session_key")
if not (platform_str and chat_id):
- return None
+ continue # BASE: an incomplete marker falls through to the next path, not "unresolved"
platform = Platform(platform_str)
adapter = self.adapters.get(platform)
if not adapter:
diff --git a/hermes_cli/backup.py b/hermes_cli/backup.py
index 5af0a41f5b1..7e564f2d811 100644
--- a/hermes_cli/backup.py
+++ b/hermes_cli/backup.py
@@ -192,10 +192,17 @@ def _collect_memory_provider_external_paths() -> List[Path]:
return []
out: Dict[Path, Path] = {} # resolved -> first declared spelling
for raw in declared:
- with suppress(Exception):
+ try:
p = Path(raw).expanduser()
- if p.exists():
- out.setdefault(p.resolve(), p)
+ except Exception:
+ continue
+ if not p.exists():
+ continue
+ try:
+ resolved = p.resolve()
+ except (OSError, ValueError):
+ continue
+ out.setdefault(resolved, p)
return list(out.values())
@@ -410,11 +417,14 @@ def _foreign_db_holder_pids(db_path: Path) -> Optional[List[int]]:
def _canonical(path: str) -> str:
return os.path.normcase(os.path.abspath(path.removesuffix(" (deleted)")))
- def _holds_watched(fd_dir: str) -> bool:
- for fd in os.listdir(fd_dir):
- with suppress(OSError):
- if _canonical(os.readlink(f"{fd_dir}/{fd}")) in watched:
- return True
+ def _holds_watched(fds: List[str], fd_dir: str) -> bool:
+ for fd in fds:
+ try:
+ target = os.readlink(f"{fd_dir}/{fd}")
+ except OSError:
+ continue
+ if _canonical(target) in watched:
+ return True
return False
canonical_db = _canonical(os.fspath(db_path))
@@ -425,9 +435,13 @@ def _foreign_db_holder_pids(db_path: Path) -> Optional[List[int]]:
for pid_str in os.listdir("/proc"):
if not pid_str.isdigit() or int(pid_str) == own_pid:
continue
- with suppress(OSError):
- if _holds_watched(f"/proc/{pid_str}/fd"):
- pids.append(int(pid_str))
+ fd_dir = f"/proc/{pid_str}/fd"
+ try:
+ fds = os.listdir(fd_dir)
+ except OSError:
+ continue
+ if _holds_watched(fds, fd_dir):
+ pids.append(int(pid_str))
except OSError:
return None
return pids
diff --git a/tools/mcp_oauth.py b/tools/mcp_oauth.py
index 47cd867670e..dbd8917de31 100644
--- a/tools/mcp_oauth.py
+++ b/tools/mcp_oauth.py
@@ -157,13 +157,15 @@ def _cached_redirect(storage: "HermesTokenStorage | None") -> "tuple[str | None,
it gets ``redirect_uri does not match any registered URIs``."""
uri = port = None
for raw in (_cached_client_info(storage) or {}).get("redirect_uris") or []:
- with contextlib.suppress(TypeError, ValueError):
+ try:
parsed = urlparse(str(raw))
- if uri is None and parsed.scheme == "https" and parsed.netloc:
- uri = str(raw)
- is_loopback_callback = parsed.scheme == "http" and parsed.path == "/callback" and parsed.hostname in {"127.0.0.1", "localhost"}
- if port is None and is_loopback_callback and parsed.port is not None:
- port = int(parsed.port)
+ except (TypeError, ValueError):
+ continue
+ if uri is None and parsed.scheme == "https" and parsed.netloc:
+ uri = str(raw)
+ is_loopback_callback = parsed.scheme == "http" and parsed.path == "/callback" and parsed.hostname in {"127.0.0.1", "localhost"}
+ if port is None and is_loopback_callback and parsed.port is not None:
+ port = int(parsed.port)
return uri, port
diff --git a/tools/wake_word.py b/tools/wake_word.py
index a5ec2589a53..b7dc391a328 100644
--- a/tools/wake_word.py
+++ b/tools/wake_word.py
@@ -497,8 +497,10 @@ class WakeWordDetector:
try:
self._audio_q.put_nowait(chunk)
except Exception:
- with suppress(Exception): # full: drop the oldest frame, then retry once
+ # Drop oldest on overflow so we stay real-time
+ with suppress(Exception):
self._audio_q.get_nowait()
+ with suppress(Exception):
self._audio_q.put_nowait(chunk)
def start(self) -> None:
@@ -703,9 +705,12 @@ def _acquire_machine_lock(path: Optional[Path] = None):
def _release_machine_lock(handle) -> None:
if handle is None:
return
- with suppress(OSError):
+ try:
_flock(handle, False)
- handle.close()
+ except OSError:
+ pass
+ finally:
+ handle.close()
def _teardown_locked(close: Callable[[], None]) -> None: