Skip to content

Commit c3e26f5

Browse files
committed
fixup: feedback
1 parent 4ccabde commit c3e26f5

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

py/src/braintrust/btx/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ def vcr_config() -> dict:
142142
return {
143143
"record_mode": record_mode,
144144
"decode_compressed_response": True,
145+
# Match on method + URI + body: the request payload (model, messages, etc.)
146+
# is what determines which cassette response is appropriate.
147+
# Volatile per-version metadata lives in headers, not the body, so we strip
148+
# those via filter_headers instead of dropping body from match_on.
145149
"match_on": ["method", "scheme", "host", "port", "path", "query", "body"],
146150
"filter_headers": [
147151
"authorization",
@@ -152,6 +156,19 @@ def vcr_config() -> dict:
152156
"openai-api-key",
153157
"x-goog-api-key",
154158
"x-bt-auth-token",
159+
# Stainless SDK telemetry headers — version-specific, not part of the
160+
# request semantics; strip so cassettes survive SDK version bumps.
161+
"user-agent",
162+
"User-Agent",
163+
"x-stainless-arch",
164+
"x-stainless-async",
165+
"x-stainless-lang",
166+
"x-stainless-os",
167+
"x-stainless-package-version",
168+
"x-stainless-runtime",
169+
"x-stainless-runtime-version",
170+
"x-stainless-read-timeout",
171+
"x-stainless-retry-count",
155172
],
156173
}
157174

py/src/braintrust/btx/test_btx.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,23 @@ def _load_specs() -> list[LlmSpanSpec]:
4949
spec_root = _SPEC_CACHE_DIR / ref / "test" / "llm_span"
5050

5151
if not spec_root.exists():
52-
return []
52+
raise FileNotFoundError(
53+
f"BTX spec root not found: {spec_root}\n"
54+
"This module must be collected after conftest.py's pytest_configure hook "
55+
"has run (which sets BTX_SPEC_ROOT). If you are seeing this error, "
56+
"try running via pytest rather than importing directly."
57+
)
5358
return load_specs(spec_root=spec_root, providers=_SUPPORTED_PROVIDERS)
5459

5560

5661
_all_specs: list[LlmSpanSpec] = _load_specs()
5762

63+
if not _all_specs:
64+
raise RuntimeError(
65+
f"No BTX specs found for providers {_SUPPORTED_PROVIDERS} under {os.environ.get('BTX_SPEC_ROOT')}. "
66+
"Check that the spec ref is correct and the spec repo contains the expected YAML files."
67+
)
68+
5869
# ---------------------------------------------------------------------------
5970
# Test
6071
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)