fix(cli): suppress SyntaxWarning in _voice_processing by moving return out of finally - #25570
alaamohanad169-ship-it wants to merge 3 commits into
Conversation
The installer creates ~/.hermes/.env via cp or touch, both of which inherit the process umask. On Ubuntu (umask 0022) the result is 0644; on some server environments with umask 0002 the result is 0664. No explicit chmod was applied after file creation, leaving API keys and tokens visible to other users on the system. Add chmod 0600 immediately after .env creation in copy_config_templates(), with a || true fallback for NixOS/containers where the activation script owns permissions. Also tightens permissions when the file already exists, so users with 0664 on disk are hardened on next upgrade. Fixes #25477
When shutdown_forensics.py detects ppid == 1, it assumes the process
runs under systemd. On macOS, PID 1 is launchd, not systemd. This
causes the gateway to incorrectly use systemd-specific shutdown logic
on macOS.
Restrict the ppid == 1 heuristic to Linux only:
sys.platform.startswith("linux") and ppid == 1
The INVOCATION_ID env var check remains platform-independent (it's only
set by systemd on Linux, so no false positive on macOS).
Fixes #25508
Test plan:
- test_under_systemd_false_on_macos_when_ppid_is_one
- test_under_systemd_true_on_linux_when_ppid_is_one
- test_under_systemd_invocation_id_overrides_platform
- All 33 tests in test_shutdown_forensics.py pass
…n out of finally The return statement at the end of the no-speech-count check was nested inside the finally: block, which silently suppresses exceptions from the except clause. Moved the no-speech tracking logic (lines 9686-9709) outside of finally: so cleanup still runs via the finally: block but return executes after it, restoring normal exception semantics. No functional change.
|
Duplicate of #21100 — same return-in-finally fix for Also note: this PR bundles unrelated changes — |
|
The de-indent from the `finally` block is incomplete. The outer `if` block was moved from 12-space to 8-space indent, but the inner `_restart_recording` function and its body were left at their original indentation (16 spaces), creating an 8-space indent from the `if` — inconsistent with the rest of the file which uses 4-space indentation. Current (after this PR): if self._voice_continuous and not submitted and not self._voice_recording:
def _restart_recording():
try:
self._voice_start_recording()Expected: if self._voice_continuous and not submitted and not self._voice_recording:
def _restart_recording():
try:
self._voice_start_recording()The `threading.Thread(target=_restart_recording, ...).start()` call and any other content inside this `if` block will also need the same 4-space de-indent. |
What does this PR do?
The return statement at the end of the no-speech-count check was nested inside the
finally:block, which silently suppresses exceptions from theexceptclause.Moved the no-speech tracking logic (lines 9686-9709) outside of
finally:so cleanup still runs via thefinally:block butreturnexecutes after it, restoring normal exception semantics. No functional change.Type of Change
Changes Made
cli.py: Moved no-speech tracking and restart logic out offinally:blockTesting
python -m py_compile cli.py— syntax valid