Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

chore(core): justify the remaining quiet exception handlers repo-wide

rubenluetke10-beepb793c10fa357
diff --git a/jarvis/contacts/vcard.py b/jarvis/contacts/vcard.py
index 3477e41404..8c1c51c77c 100644
--- a/jarvis/contacts/vcard.py
+++ b/jarvis/contacts/vcard.py
@@ -148,6 +148,7 @@ def _parse_bday(value: str) -> str | None:
try:
return _validate_birthday(v)
except ValueError:
+ # Unparseable BDAY is dropped, not fatal — the rest of the card still imports.
return None
@@ -274,6 +275,8 @@ def import_records(store: ContactStore, records: list[dict[str, Any]]) -> dict[s
try:
phones.append(_normalize_phone(p))
except ValueError:
+ # Field-level sanitising: an unparseable number is dropped,
+ # not the whole record.
pass
try:
existing = store.find_by_alias(name)
diff --git a/jarvis/plugins/tool/visualize.py b/jarvis/plugins/tool/visualize.py
index ab157122e3..1580934f83 100644
--- a/jarvis/plugins/tool/visualize.py
+++ b/jarvis/plugins/tool/visualize.py
@@ -130,6 +130,7 @@ class VisualizeTool:
try:
spec = parse_spec(args or {}, source_utterance=_utterance(ctx))
except VisualSpecError as exc:
+ # Reported through the ToolResult's own error field, not a log call.
return ToolResult(success=False, output={"kind": args.get("kind")}, error=str(exc))
try:
diff --git a/jarvis/plugins/tts/piper_local.py b/jarvis/plugins/tts/piper_local.py
index 15373f0e29..de953293de 100644
--- a/jarvis/plugins/tts/piper_local.py
+++ b/jarvis/plugins/tts/piper_local.py
@@ -242,6 +242,7 @@ class PiperLocalTTS:
chunks.put(value, timeout=0.05)
return True
except queue.Full:
+ # Consumer is just behind — retry until stopped, not an error.
continue
return False
diff --git a/jarvis/realtime/local_server/boot_progress.py b/jarvis/realtime/local_server/boot_progress.py
index bd91859089..df85d5b236 100644
--- a/jarvis/realtime/local_server/boot_progress.py
+++ b/jarvis/realtime/local_server/boot_progress.py
@@ -126,6 +126,7 @@ def read_log_tail(path: Path, *, max_bytes: int = TAIL_READ_BYTES) -> list[str]:
handle.seek(max(0, size - max(0, max_bytes)))
raw = handle.read(max(0, max_bytes))
except OSError:
+ # Log file gone or unreadable mid-boot — an empty tail, not a crash.
return []
return raw.decode("utf-8", errors="replace").splitlines()
@@ -138,6 +139,7 @@ def _line_epoch(line: str) -> float | None:
try:
return time.mktime(time.strptime(match.group(1), "%Y-%m-%d %H:%M:%S"))
except (OverflowError, ValueError):
+ # Unparseable timestamp — treat the line as untimestamped, not fatal.
return None
@@ -207,6 +209,7 @@ def load_stats(path: Path) -> BootStats:
try:
data = json.loads(path.read_text(encoding="utf-8"))
except (OSError, ValueError):
+ # Absent or corrupt file — falls through to the empty-but-valid default below.
data = None
if not isinstance(data, dict):
data = {}
diff --git a/jarvis/realtime/local_server/install.py b/jarvis/realtime/local_server/install.py
index 7ede4d2c04..6ed50cfeed 100644
--- a/jarvis/realtime/local_server/install.py
+++ b/jarvis/realtime/local_server/install.py
@@ -121,6 +121,7 @@ def _read_smoke_marker_payload() -> dict[str, object] | None:
try:
payload = json.loads(_smoke_marker().read_text(encoding="utf-8"))
except (OSError, ValueError):
+ # Absent or corrupt marker means "not proven yet" — the caller re-runs smoke.
return None
return payload if isinstance(payload, dict) else None
@@ -471,6 +472,8 @@ def _kill_tree(proc: subprocess.Popen) -> bool:
try:
proc.wait(timeout=10)
except subprocess.TimeoutExpired:
+ # Reported through the returned bool, which the caller below
+ # logs as an incomplete teardown.
return False
return proc.poll() is not None
else:
@@ -479,13 +482,17 @@ def _kill_tree(proc: subprocess.Popen) -> bool:
try:
os.killpg(proc.pid, signal.SIGTERM) # type: ignore[attr-defined]
except (ProcessLookupError, PermissionError, OSError):
+ # No process group to signal — fall back to killing just the launcher.
proc.terminate()
try:
proc.wait(timeout=10)
except subprocess.TimeoutExpired:
+ # SIGTERM did not land in time — escalate to SIGKILL; the
+ # final poll() below still reports overall success/failure.
try:
os.killpg(proc.pid, signal.SIGKILL) # type: ignore[attr-defined]
except (ProcessLookupError, PermissionError, OSError):
+ # No process group to signal — fall back to killing just the launcher.
proc.kill()
proc.wait(timeout=10)
return proc.poll() is not None
@@ -499,6 +506,7 @@ def _port_open(port: int, timeout: float = 1.0) -> bool:
with socket.create_connection(("127.0.0.1", port), timeout=timeout):
return True
except OSError:
+ # Connection refused/timed out — the port simply is not open yet.
return False
@@ -927,6 +935,7 @@ def _rmtree_tolerant(root: Path) -> None:
os.chmod(path, stat.S_IWRITE)
func(path)
except FileNotFoundError:
+ # Vanished during the retry — already gone, same as the check above.
return
last_error: OSError | None = None
@@ -992,6 +1001,7 @@ def _uninstall_guarded() -> tuple[bool, str]:
try:
_rmtree_tolerant(root)
except OSError as exc:
+ # Reported through the returned (ok, message) tuple, not a log call.
return False, f"could not remove {root}: {exc}"
_clear_managed_config(root)
with _LOCK:
diff --git a/jarvis/realtime/local_server/model_catalog.py b/jarvis/realtime/local_server/model_catalog.py
index 925a630c67..008631631b 100644
--- a/jarvis/realtime/local_server/model_catalog.py
+++ b/jarvis/realtime/local_server/model_catalog.py
@@ -455,6 +455,7 @@ def _flag_value(command: str, flag: str) -> str:
tokens = shlex.split(command or "", posix=os.name != "nt")
except ValueError:
+ # Unbalanced quotes in a stored command — treat as "flag not found".
return ""
value = ""
lowered_flag = flag.lower()
diff --git a/jarvis/realtime/local_server/patching.py b/jarvis/realtime/local_server/patching.py
index 2354569622..b3d8b4e042 100644
--- a/jarvis/realtime/local_server/patching.py
+++ b/jarvis/realtime/local_server/patching.py
@@ -110,6 +110,7 @@ def patch_state(site_packages: Path) -> str:
try:
digest = _sha256(target.read_bytes())
except OSError:
+ # Reported through the documented "missing" return state, not a log call.
return "missing"
if digest == PRISTINE_SHA256:
return "pristine"
@@ -157,6 +158,7 @@ def pocket_language_patch_state(site_packages: Path) -> str:
try:
digest = _sha256(target.read_bytes())
except OSError:
+ # Reported through the documented "missing" return state, not a log call.
return "missing"
if digest == POCKET_HANDLER_PRISTINE_SHA256:
return "pristine"
diff --git a/jarvis/realtime/local_server/preflight.py b/jarvis/realtime/local_server/preflight.py
index cabe8da479..74ba89bef4 100644
--- a/jarvis/realtime/local_server/preflight.py
+++ b/jarvis/realtime/local_server/preflight.py
@@ -71,6 +71,7 @@ def _disk_free_gb(root: Path) -> float:
try:
return shutil.disk_usage(probe).free / (1024**3)
except OSError:
+ # Unreadable filesystem — 0 free is the honest, fail-safe answer.
return 0.0
diff --git a/jarvis/realtime/local_server/supervisor.py b/jarvis/realtime/local_server/supervisor.py
index b62971bbe0..9173c4090c 100644
--- a/jarvis/realtime/local_server/supervisor.py
+++ b/jarvis/realtime/local_server/supervisor.py
@@ -170,6 +170,7 @@ def _host_port(base_url: str) -> tuple[str, int]:
try:
port = parsed.port or _DEFAULT_PORT
except ValueError:
+ # Unparseable port in a stored address — fall back to the pinned default.
port = _DEFAULT_PORT
return parsed.hostname or "127.0.0.1", port
@@ -183,6 +184,7 @@ def _port_open(port: int, timeout: float = 1.0) -> bool:
with socket.create_connection(("127.0.0.1", port), timeout=timeout):
return True
except OSError:
+ # Connection refused/timed out — the port simply is not open yet.
return False
@@ -196,6 +198,7 @@ def _pool_url(base_url: str) -> str:
try:
port = parsed.port or _DEFAULT_PORT
except ValueError:
+ # Unparseable port in a stored address — fall back to the pinned default.
port = _DEFAULT_PORT
default_port = 443 if parsed.scheme == "https" else 80
netloc = host_text if port == default_port else f"{host_text}:{port}"
@@ -242,6 +245,7 @@ def probe_runtime(base_url: str, timeout: float = 0.75) -> dict[str, int] | None
return None
raw = response.read(_MAX_POOL_RESPONSE_BYTES + 1)
except (http.client.HTTPException, OSError, TimeoutError, ValueError):
+ # Reported through the documented "None means not ready" return contract above.
return None
finally:
connection.close()
@@ -250,6 +254,7 @@ def probe_runtime(base_url: str, timeout: float = 0.75) -> dict[str, int] | None
try:
payload = json.loads(raw.decode("utf-8"))
except (UnicodeDecodeError, ValueError):
+ # Reported through the documented "None means not ready" return contract above.
return None
if not isinstance(payload, dict):
return None
@@ -418,10 +423,12 @@ def _read_pidfile() -> dict[str, object] | None:
try:
raw = _pidfile().read_text(encoding="utf-8")
except OSError:
+ # No pidfile written yet, or unreadable — treat as "not owned".
return None
try:
data = json.loads(raw)
except ValueError:
+ # Corrupt pidfile — same "not owned" outcome as a missing one.
return None
return data if isinstance(data, dict) else None
@@ -432,6 +439,7 @@ def _json_int(value: object) -> int | None:
try:
return int(value)
except ValueError:
+ # Non-numeric string in a stored/received field — treated as absent.
return None
@@ -441,6 +449,7 @@ def _json_float(value: object) -> float | None:
try:
return float(value)
except ValueError:
+ # Non-numeric string in a stored/received field — treated as absent.
return None
@@ -460,6 +469,7 @@ def _process_create_time(pid: int) -> float | None:
try:
import psutil # type: ignore[import-untyped] # lazy, optional
except ImportError:
+ # psutil not installed — ownership falls back to the caller's other checks.
return None
try:
process = psutil.Process(pid)
@@ -600,6 +610,7 @@ def _try_lock_file(handle: BinaryIO) -> bool:
)
return True
except OSError:
+ # Already locked by another process/thread — reported through the bool.
return False
@@ -868,6 +879,7 @@ def _command_references_root(command: str, root: Path) -> bool:
tokens = shlex.split(command, posix=os.name != "nt")
resolved_root = root.resolve()
except (OSError, ValueError):
+ # Unparseable command or unresolvable root — reported via the returned bool.
return False
for token in tokens:
candidate = token.split("=", 1)[-1].strip("\"'")
@@ -877,6 +889,7 @@ def _command_references_root(command: str, root: Path) -> bool:
if Path(candidate).resolve().is_relative_to(resolved_root):
return True
except OSError:
+ # This one token cannot be resolved — check the remaining ones.
continue
return False
@@ -954,6 +967,7 @@ def _cli_flag_value(command: str, flag: str) -> str | None:
tokens = shlex.split(command, posix=os.name != "nt")
except ValueError:
+ # Unbalanced quotes in a stored command — treat as "flag not found".
return None
value: str | None = None
normalized_flag = flag.lower()
@@ -1044,6 +1058,7 @@ def _uses_loopback_bind(command: str) -> bool:
tokens = shlex.split(command, posix=os.name != "nt")
except ValueError:
+ # Unbalanced quotes in a stored command — treat as "not explicitly loopback".
return False
host: str | None = None
for index, token in enumerate(tokens):
@@ -1797,8 +1812,11 @@ def _kill_pid_tree(pid: int) -> bool:
try:
os.killpg(pid, signal.SIGTERM) # type: ignore[attr-defined]
except ProcessLookupError:
+ # Already gone — reported through the returned True, same as a
+ # confirmed kill.
return True
except (PermissionError, OSError):
+ # No process group to signal — fall back to killing just the pid.
os.kill(pid, signal.SIGTERM)
deadline = time.monotonic() + 5.0
while time.monotonic() < deadline:
@@ -1808,8 +1826,11 @@ def _kill_pid_tree(pid: int) -> bool:
try:
os.killpg(pid, signal.SIGKILL) # type: ignore[attr-defined]
except ProcessLookupError:
+ # Already gone — reported through the returned True, same as a
+ # confirmed kill.
return True
except (PermissionError, OSError):
+ # No process group to signal — fall back to killing just the pid.
os.kill(pid, signal.SIGKILL) # type: ignore[attr-defined]
return True
except Exception: # noqa: BLE001 — best-effort teardown, reported honestly
@@ -1858,10 +1879,13 @@ def _pid_exists(pid: int) -> bool:
try:
os.kill(pid, 0)
except ProcessLookupError:
+ # No such pid — reported through the returned False.
return False
except PermissionError:
+ # Exists but not ours to signal — still alive, reported through True.
return True
except OSError:
+ # Any other kill(0) failure means the pid does not resolve to a live process.
return False
return True
@@ -1875,6 +1899,7 @@ def _path_is_within_root(value: str, root: Path) -> bool:
try:
candidate = Path(text).resolve()
except OSError:
+ # Unresolvable path — reported through the returned False.
return False
return candidate == root or candidate.is_relative_to(root)
@@ -1889,6 +1914,7 @@ def _lexical_path_is_within_root(value: str, root: Path) -> bool:
try:
return os.path.commonpath((candidate, root_text)) == root_text
except ValueError:
+ # Paths on different drives/roots — reported through the returned False.
return False
@@ -1932,6 +1958,7 @@ def reconcile_ready_ownership(*, launch_command: str, base_url: str) -> bool:
try:
import psutil # type: ignore[import-untyped]
except ImportError:
+ # psutil not installed — adoption is skipped, reported via the returned False.
return False
candidates: list[Any] = []
@@ -1972,6 +1999,7 @@ def _kill_by_install_root(root: Path) -> tuple[int, int]:
try:
resolved_root = root.resolve()
except OSError:
+ # Unresolvable root — nothing to sweep, reported through the (0, 0) result.
return 0, 0
if resolved_root.name.lower() != "local_realtime" or not resolved_root.exists():
log.warning("supervisor: refused unsafe install-root sweep of %s", resolved_root)
@@ -2008,6 +2036,7 @@ def _kill_by_install_root(root: Path) -> tuple[int, int]:
proc.kill()
signalled.append(proc)
except psutil.NoSuchProcess:
+ # Already gone — tracked via the vanished counter, not a failure to log.
vanished += 1
except (psutil.Error, OSError):
failed += 1
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index df2b1b740b..740b2baef4 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -5039,6 +5039,8 @@ class RealtimeVoiceSession:
try:
await self._session.request_response(required_tool=None)
except TypeError:
+ # Older transport signature without required_tool — retry
+ # with the plain call, not a failure to report.
await self._session.request_response()
log.info(
"realtime[%s] retrying one blocked output in %s",
@@ -6712,6 +6714,8 @@ class RealtimeVoiceSession:
try:
error = done.exception()
except asyncio.CancelledError:
+ # Race with the cancelled() check above — already covered by
+ # the log call there, nothing new to report here.
return
if error is not None:
log.warning(
@@ -7733,6 +7737,8 @@ class RealtimeVoiceSession:
timeout=max(0.05, float(timeout_s or 2.5)),
)
except TimeoutError:
+ # Tracked via the failure counter, not logged per-call — a slow
+ # grounding search is an expected outcome, not a bug to chase.
self._public_fact_grounding_failures += 1
return uncertainty, False
except asyncio.CancelledError:
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index 2d3771d588..ef34036557 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -4159,6 +4159,7 @@ class DesktopApp:
try:
window.destroy()
except Exception as exc: # noqa: BLE001
+ # Reported through the returned reason field, not a log call.
return {"ok": False, "reason": f"{type(exc).__name__}: {exc}"}
return {"ok": True, "view": view}
@@ -4269,6 +4270,7 @@ class DesktopApp:
try:
window.destroy()
except Exception: # noqa: BLE001, S110
+ # Teardown best-effort: the window may already be gone.
pass
def _main_window_kwargs(self) -> dict[str, Any]:
diff --git a/jarvis/ui/web/outputs_routes.py b/jarvis/ui/web/outputs_routes.py
index 5aacf6ad45..55d9a12d96 100644
--- a/jarvis/ui/web/outputs_routes.py
+++ b/jarvis/ui/web/outputs_routes.py
@@ -732,6 +732,8 @@ def _collect_graph_files(session_dir: Path) -> list[dict[str, Any]]:
try:
stat = child.stat()
except OSError:
+ # A file can disappear mid-walk; skip it, the graph still
+ # draws the rest.
continue
files.append({"path": "/".join(rel_parts), "size": stat.st_size})
if len(files) >= _ARTIFACT_MAX_LISTING:
diff --git a/jarvis/ui/web/run_plan.py b/jarvis/ui/web/run_plan.py
index c407bc3344..852448152b 100644
--- a/jarvis/ui/web/run_plan.py
+++ b/jarvis/ui/web/run_plan.py
@@ -141,6 +141,7 @@ def _walk_stream(stream_text: str, task_key: str) -> tuple[list[dict[str, Any]],
try:
obj = json.loads(line)
except (json.JSONDecodeError, ValueError):
+ # A malformed line is skipped, not fatal — the rest of the stream still parses.
continue
if not isinstance(obj, dict):
continue