fix(stockplatform): load runtime before recovery preflight
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 56s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

This commit is contained in:
Your Name
2026-07-02 19:37:18 +08:00
parent b191f8e9fe
commit 08ccceacb6
2 changed files with 21 additions and 5 deletions

View File

@@ -1207,8 +1207,12 @@ async def get_stockplatform_public_api_runtime_readback() -> dict[str, Any]:
async def get_stockplatform_public_api_controlled_recovery_preflight() -> dict[str, Any]:
"""回傳 StockPlatform public API controlled recovery preflight。"""
try:
runtime_readback = await asyncio.to_thread(
load_latest_stockplatform_public_api_runtime_readback
)
payload = await asyncio.to_thread(
load_latest_stockplatform_public_api_controlled_recovery_preflight
load_latest_stockplatform_public_api_controlled_recovery_preflight,
runtime_readback=runtime_readback,
)
return redact_public_lan_topology(payload)
except (json.JSONDecodeError, ValueError) as exc:

View File

@@ -188,13 +188,25 @@ def test_stockplatform_controlled_recovery_preflight_endpoint_returns_payload(
monkeypatch,
tmp_path: Path,
):
runtime_payload = _runtime_blocked()
monkeypatch.setattr(
agents,
"load_latest_stockplatform_public_api_runtime_readback",
lambda: runtime_payload,
)
def _load_preflight(*, runtime_readback: dict):
assert runtime_readback is runtime_payload
return load_latest_stockplatform_public_api_controlled_recovery_preflight(
runtime_readback=runtime_readback,
route_source_path=_route_source(tmp_path),
)
monkeypatch.setattr(
agents,
"load_latest_stockplatform_public_api_controlled_recovery_preflight",
lambda: load_latest_stockplatform_public_api_controlled_recovery_preflight(
runtime_readback=_runtime_blocked(),
route_source_path=_route_source(tmp_path),
),
_load_preflight,
)
app = FastAPI()
app.include_router(router, prefix="/api/v1")