refactor(errors): replace silent exception handling in console and server

This commit is contained in:
somew1nd committed 2026-09-01 17:57:15 -07:00
1 parent 41deb48005
commit c76c9bb7e8
20 files changed
+267 -107

No files matched your search

+6 -3
View File
@@ -83,7 +83,8 @@ def _list_sessions_sync():
d_info = json.loads(d_info_raw) if isinstance(d_info_raw, str) else d_info_raw
if isinstance(d_info, dict):
device_id = d_info.get("device_id") or d_info.get("device_serial")
except Exception:
except (ValueError, TypeError):
# Malformed device_info JSON: fall back to the recording's device_id.
pass
if not device_id and recording:
device_id = recording.get("device_id")
@@ -157,8 +158,10 @@ def _list_sessions_sync():
"failed",
error="Process terminated unexpectedly (auto-harvested).",
)
except Exception:
pass
except OSError as e:
# read_status never raises; this guards the lock/write side
# of update_trace_status.
print(f"[list_sessions] Could not mark harvested traces failed: {e}")
except Exception as e:
print(f"[list_sessions] Failed to update orphaned sessions: {e}")
+2 -1
View File
@@ -78,7 +78,8 @@ async def get_trace(trace_id: str, session_id: str = None, step_number: int = No
try:
payload_obj = json.loads(trace_dict["payload"])
trace_dict["payload"] = media_service.unwrap_payload(payload_obj)
except Exception:
except (ValueError, TypeError, KeyError, AttributeError):
# Non-JSON or unexpectedly shaped payload: serve it raw.
pass
return trace_dict
+2 -1
View File
@@ -209,7 +209,8 @@ async def stop_task(
target_sid = str(body["session_id"])
if body.get("device_id"):
target_dev = str(body["device_id"])
except Exception:
except ValueError:
# Empty or non-JSON body: fall back to the query parameters.
pass
stopped = task_queue_service.stop_tasks(