fix(health): preserve transient failure codes through stale snapshot fallback

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-12 13:37:45 +00:00
committed by GitHub
co-authored by genichin
parent 4a2e7dd893
commit 9c5a01ed67
3 changed files with 25 additions and 4 deletions
+8 -1
View File
@@ -214,6 +214,7 @@ class AccountSnapshotService:
def holdings_for_sell(self) -> list[BalanceItem]:
"""Prefer a live balance; fallback only on transient transport failure."""
transient_code: str | None = None
try:
return self._broker.get_balance()
except BrokerBalanceError as exc:
@@ -221,8 +222,14 @@ class AccountSnapshotService:
raise AccountSnapshotUnavailable(
"live_read_failed", detail_code=exc.code
) from None
transient_code = exc.code
snapshot = self._load_current()
age = self._age(snapshot.holdings_captured_at, self._sell_max_age)
try:
age = self._age(snapshot.holdings_captured_at, self._sell_max_age)
except AccountSnapshotUnavailable as exc:
raise AccountSnapshotUnavailable(
exc.code, detail_code=transient_code
) from None
_log.warning(
"sell balance using account snapshot: age_sec=%.0f",
age,