fix(types): T4 — stop spreading TopologySummary as dict; fix heartbeat .get() and scope param

This commit is contained in:
2026-05-01 01:51:43 -04:00
parent d637ff515e
commit e387acf79d
6 changed files with 11 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ from __future__ import annotations
import hashlib
import json
from datetime import datetime, timezone
from collections.abc import MutableMapping
from typing import Any, Optional
from fastapi import APIRouter, Depends, HTTPException, Request
@@ -39,7 +40,7 @@ class HeartbeatRequest(BaseModel):
topology: Optional[dict[str, Any]] = None
def _extract_peer_fingerprint(scope: dict[str, Any]) -> Optional[str]:
def _extract_peer_fingerprint(scope: MutableMapping[str, Any]) -> Optional[str]:
"""Pull the peer cert's SHA-256 fingerprint from an ASGI scope.
Tries two extraction paths because uvicorn has historically stashed
@@ -127,7 +128,7 @@ async def _reconcile_topology_report(
# Non-fatal: reconcile is best-effort; the host stays alive regardless
log.exception("heartbeat: could not list active topologies")
return
mine = [t for t in topos if t.get("target_host_uuid") == host_uuid]
mine = [t for t in topos if t.target_host_uuid == host_uuid]
if not mine:
return