fix(healing): handle post-heal verify exceptions without crashing loop

This commit is contained in:
patrick committed 2026-03-01 21:14:59 -05:00
1 parent 9edce6b31d
commit 9b53a4c491
2 files changed
+51 -13

No files matched your search

+27 -12
View File
@@ -105,19 +105,34 @@ def execute_heal_and_verify(auditor, reporter, count, drift, heal_verify_delay):
f"(pre_fingerprint={drift.get('fingerprint', '')})."
)
time.sleep(heal_verify_delay)
post_is_synced, post_count, post_drift = auditor.reconcile()
heal_result = "success" if post_is_synced else "failed"
verify_error = None if post_is_synced else "Post-heal verification failed"
reporter.update_status(post_is_synced, post_count, last_error=verify_error)
try:
post_is_synced, post_count, post_drift = auditor.reconcile()
heal_result = "success" if post_is_synced else "failed"
verify_error = None if post_is_synced else "Post-heal verification failed"
reporter.update_status(post_is_synced, post_count, last_error=verify_error)
logging.warning(
"Post-heal verification result "
f"result={heal_result} pre={drift.get('fingerprint', '')} "
f"post={post_drift.get('fingerprint', '')} "
f"missing={post_drift.get('missing_count', 0)} "
f"extra={post_drift.get('extra_count', 0)} "
f"metadata={post_drift.get('metadata_drift_count', 0)}"
)
logging.warning(
"Post-heal verification result "
f"result={heal_result} pre={drift.get('fingerprint', '')} "
f"post={post_drift.get('fingerprint', '')} "
f"missing={post_drift.get('missing_count', 0)} "
f"extra={post_drift.get('extra_count', 0)} "
f"metadata={post_drift.get('metadata_drift_count', 0)}"
)
except Exception as e:
heal_result = "verify_error"
reporter.update_status(False, count, last_error=f"Post-heal verify error: {e}")
post_drift = {
"reason": "verify_error",
"missing_count": 0,
"extra_count": 0,
"metadata_drift_count": 0,
"fingerprint": "",
}
logging.error(
"Post-heal verification crashed "
f"(pre_fingerprint={drift.get('fingerprint', '')}): {e}"
)
else:
reporter.update_status(False, count, last_error="Bouncer restart failed")
logging.error(