Skip to content

Commit aea7af9

Browse files
committed
fix(federation): drop non-dict entries in PeerRegistry.get
A peer returning a registry list with a stray non-dict entry (e.g. `[{"name":"foo"}, "junk", 42]`) crashed `aggregate()` at `dict(e)` with a ValueError. The exception propagated up through `/registry/global`, 500'ing the response and taking the local hub's own listings down with it — a direct violation of the module's 'peer failures never block the local response' contract. Filter non-dict rows out of the returned list at the same fetch-boundary guard that already coerces non-list bodies to empty. Cache stays clean; aggregate() sees only well-shaped entries.
1 parent 21a43c3 commit aea7af9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

zhub/federation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ async def get(self, peer_url: str) -> list[dict[str, Any]]:
5757
if not isinstance(data, list):
5858
log.warning("peer %s returned non-list registry; treating as empty", peer_url)
5959
data = []
60+
else:
61+
# Individual non-dict entries (a peer returning
62+
# ``[{"name":"x"}, "junk", 42]``) crash aggregate() at
63+
# ``dict(e)``; one bad row would 500 /registry/global,
64+
# dropping the local hub's own listings too.
65+
data = [e for e in data if isinstance(e, dict)]
6066
except Exception as e:
6167
log.warning("peer %s unreachable: %s", peer_url, e)
6268
# Negatively cache the failure: without this a dead peer is

0 commit comments

Comments
 (0)