Skip to content

Commit 8b01aa0

Browse files
committed
test(federation): pin non-dict entry drop + aggregate survival
Regression test for the ValueError from `dict(<non-dict>)` inside aggregate(). Mixes valid dict rows with a string / int / null in the mock peer registry and asserts get() returns only the dicts and aggregate() carries them through with origin annotations.
1 parent aea7af9 commit 8b01aa0

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/test_federation_cache.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@ def handler(request):
8282
await pr.close()
8383

8484

85+
async def test_non_dict_entries_dropped_from_registry():
86+
"""A peer registry with mixed dict / non-dict entries returns only the
87+
dict rows — regression for aggregate() crashing at ``dict(e)`` on a
88+
string/int entry, which would have 500'd /registry/global on the local
89+
hub and taken its own listings down with it."""
90+
def handler(request):
91+
return httpx.Response(200, json=[{"name": "good"}, "junk", 42, None,
92+
{"name": "also-good"}])
93+
94+
pr = _registry(["http://peer.example"], handler)
95+
try:
96+
assert await pr.get("http://peer.example") == [
97+
{"name": "good"}, {"name": "also-good"},
98+
]
99+
out = await pr.aggregate()
100+
assert [e["name"] for e in out] == ["good", "also-good"]
101+
assert all(e["origin"] == "http://peer.example" for e in out)
102+
finally:
103+
await pr.close()
104+
105+
85106
async def test_aggregate_annotates_origin():
86107
"""aggregate() tags every peer entry with its origin URL."""
87108
def handler(request):

0 commit comments

Comments
 (0)