refactor(errors): replace silent exception handling in console and server
This commit is contained in:
1 parent
41deb48005
commit
c76c9bb7e8
20 files changed
+267
-107
No files matched your search
@@ -12,11 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
from artemis.runtime import trace_store
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from admin_console.database.connection import db_session
|
||||
except ImportError:
|
||||
@@ -317,8 +320,15 @@ class SessionRepository:
|
||||
"failed",
|
||||
error="Process terminated prior to server startup.",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except OSError as exc:
|
||||
# read_status itself never raises; this guards the
|
||||
# lock/write side of update_trace_status.
|
||||
logger.warning(
|
||||
"Could not mark trace %s failed during orphan "
|
||||
"reconciliation: %s",
|
||||
row["session_id"],
|
||||
exc,
|
||||
)
|
||||
conn.commit()
|
||||
return count
|
||||
except Exception:
|
||||
|
||||
@@ -106,7 +106,8 @@ class StepRepository:
|
||||
if isinstance(payload_raw, str):
|
||||
try:
|
||||
payload_obj = json.loads(payload_raw)
|
||||
except Exception:
|
||||
except (ValueError, TypeError):
|
||||
# Non-JSON payload: the isinstance(dict) guard below bails out.
|
||||
pass
|
||||
if not isinstance(payload_obj, dict):
|
||||
return 0, 0, 0
|
||||
@@ -175,7 +176,8 @@ class StepRepository:
|
||||
if isinstance(payload_raw, str):
|
||||
try:
|
||||
payload_obj = json.loads(payload_raw)
|
||||
except Exception:
|
||||
except (ValueError, TypeError):
|
||||
# Non-JSON payload: the isinstance(dict) guard below bails out.
|
||||
pass
|
||||
|
||||
if not isinstance(payload_obj, dict):
|
||||
@@ -308,7 +310,8 @@ class StepRepository:
|
||||
if step_dict.get(json_col):
|
||||
try:
|
||||
step_dict[json_col] = json.loads(step_dict[json_col])
|
||||
except Exception:
|
||||
except (ValueError, TypeError):
|
||||
# Non-JSON column value: keep the raw string.
|
||||
pass
|
||||
|
||||
# If post_image_name is identical to pre_image_name, normalize to None
|
||||
@@ -471,7 +474,8 @@ class StepRepository:
|
||||
p_raw_th.append(str(th_text).strip())
|
||||
elif thr["type"] == "thinking" and th_text:
|
||||
p_nat_th.append(str(th_text).strip())
|
||||
except Exception:
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
# Unparseable or non-dict thinking payload: skip it.
|
||||
pass
|
||||
|
||||
virtual_step = {
|
||||
|
||||
@@ -52,7 +52,8 @@ class TraceRepository:
|
||||
if row_dict.get("payload"):
|
||||
try:
|
||||
row_dict["payload"] = json.loads(row_dict["payload"])
|
||||
except Exception:
|
||||
except (ValueError, TypeError):
|
||||
# Non-JSON payload: keep the raw string for display.
|
||||
pass
|
||||
nodes[row_dict["trace_id"]] = {**row_dict, "children": []}
|
||||
|
||||
@@ -94,7 +95,8 @@ class TraceRepository:
|
||||
if row_dict.get("payload"):
|
||||
try:
|
||||
row_dict["payload"] = json.loads(row_dict["payload"])
|
||||
except Exception:
|
||||
except (ValueError, TypeError):
|
||||
# Non-JSON payload: keep the raw string for display.
|
||||
pass
|
||||
nodes[row_dict["trace_id"]] = {**row_dict, "children": []}
|
||||
|
||||
|
||||
Reference in new issue
Block a user