Skip to content

Commit fceaa9f

Browse files
Guard _assert_error_span_extras against duplicate span names (#231)
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.
1 parent 338e4b8 commit fceaa9f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/conformance/test_observability.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,6 +3906,11 @@ def _walk(entries: list[dict[str, Any]]) -> None:
39063906
name = cast("str", entry["name"])
39073907
candidates = by_name.get(name, [])
39083908
assert candidates, f"expected a span named {name!r}; got {sorted(by_name)}"
3909+
assert len(candidates) == 1, (
3910+
f"_assert_error_span_extras assumes unique span names; {name!r} matched "
3911+
f"{len(candidates)}. Add name+attribute disambiguation if a fixture emits "
3912+
f"multiple same-named spans (e.g. call-level retry)."
3913+
)
39093914
span = candidates[0]
39103915
desc = entry.get("status_description")
39113916
if desc is not None:

0 commit comments

Comments
 (0)