From 2c528eabccaadfe7ad4a26a3fd715df326efea2a Mon Sep 17 00:00:00 2001 From: chris-colinsky Date: Thu, 23 Jul 2026 10:34:56 -0700 Subject: [PATCH] Guard _assert_error_span_extras against duplicate span names Address CoPilot review on #230 (the guard landed after the squash-merge). _assert_error_span_extras picked candidates[0] for a span name; with a single-attempt fixture (124) names are unique, but a future fixture with multiple same-named spans (e.g. call-level retry) could silently assert the wrong span. Assert exactly one candidate so that case fails loudly here instead, rather than duplicating _assert_span_tree_matches's full name+attribute disambiguation. Test-only; no behavior change. --- tests/conformance/test_observability.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/conformance/test_observability.py b/tests/conformance/test_observability.py index 2bb118f..319d1a6 100644 --- a/tests/conformance/test_observability.py +++ b/tests/conformance/test_observability.py @@ -3906,6 +3906,11 @@ def _walk(entries: list[dict[str, Any]]) -> None: name = cast("str", entry["name"]) candidates = by_name.get(name, []) assert candidates, f"expected a span named {name!r}; got {sorted(by_name)}" + assert len(candidates) == 1, ( + f"_assert_error_span_extras assumes unique span names; {name!r} matched " + f"{len(candidates)}. Add name+attribute disambiguation if a fixture emits " + f"multiple same-named spans (e.g. call-level retry)." + ) span = candidates[0] desc = entry.get("status_description") if desc is not None: