Skip to content

Commit b868f91

Browse files
Tighten 044 fan-out shape assertions
From CoPilot review of #192: make the 044 build's shape assumptions explicit so a fixture-shape drift fails loudly. - Assert exactly one fan-out node (was: silently use the first). - Assert the inner node's keys are exactly {capture_invocation_metadata_into} (was: only checked the key's presence, dropping any extra directive).
1 parent 6b9915e commit b868f91

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/conformance/test_observability.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,10 @@ async def _build_and_invoke_metadata_fan_out(case: Mapping[str, Any], types_seen
15901590
from .adapter import build_state_cls # noqa: PLC0415
15911591

15921592
nodes = cast("dict[str, Any]", case["nodes"])
1593-
fan_out_name, fan_out_spec = next(
1594-
(n, cast("dict[str, Any]", s)) for n, s in nodes.items() if "fan_out" in cast("dict[str, Any]", s)
1595-
)
1593+
fan_out_names = [n for n, s in nodes.items() if "fan_out" in cast("dict[str, Any]", s)]
1594+
assert len(fan_out_names) == 1, f"044 build expects exactly one fan-out node; got {fan_out_names}"
1595+
fan_out_name = fan_out_names[0]
1596+
fan_out_spec = cast("dict[str, Any]", nodes[fan_out_name])
15961597
fan_out_cfg = cast("dict[str, Any]", fan_out_spec["fan_out"])
15971598
items_field = cast("str", fan_out_cfg["items_field"])
15981599
augment_map = cast("dict[str, str]", fan_out_cfg.get("augment_metadata_from_field") or {})
@@ -1616,8 +1617,9 @@ async def _build_and_invoke_metadata_fan_out(case: Mapping[str, Any], types_seen
16161617
)
16171618
inode_name, inode_spec_any = next(iter(inner_nodes.items()))
16181619
inode_spec = cast("dict[str, Any]", inode_spec_any)
1619-
assert "capture_invocation_metadata_into" in inode_spec, (
1620-
f"fan-out inner node {inode_name!r} must declare capture_invocation_metadata_into"
1620+
assert set(inode_spec) == {"capture_invocation_metadata_into"}, (
1621+
f"fan-out inner node {inode_name!r} must declare only capture_invocation_metadata_into; "
1622+
f"got {sorted(inode_spec)}"
16211623
)
16221624
outer_target_field = cast("str", inode_spec["capture_invocation_metadata_into"])
16231625
inner_builder.add_node(inode_name, _make_metadata_capture_body(inner_capture_field, types_seen))

0 commit comments

Comments
 (0)