Skip to content

Commit c4484ab

Browse files
committed
fix(drift): probe-failure also flags a missing baseline fingerprint (#188 review)
Copilot (PR #188) noted that the probe-first ordering introduced in #186 means a probe_failed early-return no longer mentions a missing expected fingerprint: if the probe raises AND no baseline is committed, only the probe error surfaced, masking the missing-baseline config error. Route both probe-failure paths through a _probe_failed() helper that appends "expected fingerprint is missing at <path>" when the baseline file is absent, while preserving the underlying probe error. No change when a baseline exists. + regression test (probe raises + no baseline -> error mentions both).
1 parent 9424342 commit c4484ab

2 files changed

Lines changed: 40 additions & 9 deletions

File tree

hvantk/core/plugin/drift_runner.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ def run_drift_check(dataset_name: str, *, timeout: int = 60) -> DriftResult:
3737
return _run_drift_check_with_spec(spec, timeout=timeout)
3838

3939

40+
def _probe_failed(spec: DatasetSpec, exc: DriftProbeError) -> DriftResult:
41+
"""Build a probe_failed result, also flagging a missing baseline fingerprint.
42+
43+
The probe runs before the baseline is read (so intentional stubs classify
44+
correctly). Without this, a plugin whose probe fails AND ships no committed
45+
baseline would surface only the probe error and silently hide the
46+
missing-fingerprint configuration issue. The underlying probe error is
47+
preserved either way.
48+
"""
49+
fp_path = Path(spec.test_paths.drift_fingerprint)
50+
if not fp_path.exists():
51+
exc = DriftProbeError(
52+
f"{exc}; additionally, expected fingerprint is missing at {fp_path}"
53+
)
54+
return DriftResult(
55+
dataset_name=spec.name, status="probe_failed", probe_error=exc
56+
)
57+
58+
4059
def _run_drift_check_with_spec(
4160
spec: DatasetSpec, *, timeout: int = 60
4261
) -> DriftResult:
@@ -47,16 +66,10 @@ def _run_drift_check_with_spec(
4766
try:
4867
observed = _invoke_with_timeout(spec.drift_probe, timeout=timeout)
4968
except DriftProbeError as exc:
50-
return DriftResult(
51-
dataset_name=spec.name,
52-
status="probe_failed",
53-
probe_error=exc,
54-
)
69+
return _probe_failed(spec, exc)
5570
except Exception as exc: # noqa: BLE001
56-
return DriftResult(
57-
dataset_name=spec.name,
58-
status="probe_failed",
59-
probe_error=DriftProbeError(f"probe raised {type(exc).__name__}: {exc}"),
71+
return _probe_failed(
72+
spec, DriftProbeError(f"probe raised {type(exc).__name__}: {exc}")
6073
)
6174

6275
if observed.get("probe_status") == PROBE_STATUS_STUB:

hvantk/tests/test_drift_runner.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,24 @@ def boom():
9191
assert "network down" in str(result.probe_error)
9292

9393

94+
def test_probe_failure_with_missing_baseline_reports_both(tmp_path: Path):
95+
"""When the probe fails AND no baseline fingerprint is committed, the error
96+
must surface both the probe failure and the missing-fingerprint path — the
97+
probe-first ordering must not mask the missing-baseline config error
98+
(PR #188 review: Copilot)."""
99+
fp_path = tmp_path / "does-not-exist.json" # no baseline written
100+
101+
def boom():
102+
raise DriftProbeError("network down")
103+
104+
spec = _make_spec(probe_return=boom, fingerprint_path=fp_path)
105+
result = _run_with_spec(spec)
106+
assert result.status == "probe_failed"
107+
msg = str(result.probe_error)
108+
assert "network down" in msg # underlying probe error preserved
109+
assert "missing" in msg.lower() and str(fp_path) in msg # baseline flagged
110+
111+
94112
def test_fetched_at_is_excluded_from_comparison(tmp_path: Path):
95113
fp_path = tmp_path / "fp.json"
96114
_write_fingerprint(

0 commit comments

Comments
 (0)