Skip to content

Commit 0cdcf29

Browse files
authored
fix(validation): bundle schemas before wheel builds
Fixes #897 by bundling schemas before release and CI wheel builds, and by surfacing SDK-pinned missing schema bundles without warning on explicit unsupported version probes.
1 parent 62fa7ff commit 0cdcf29

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ jobs:
171171
- name: Build and install wheel
172172
run: |
173173
python -m pip install --upgrade pip build
174+
python scripts/bundle_schemas.py
174175
python -m build --wheel --outdir dist/
175176
pip install dist/*.whl
176177

.github/workflows/release-please.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ jobs:
9595
python -m pip install --upgrade pip
9696
pip install build twine
9797
98+
- name: Bundle schemas
99+
if: ${{ steps.release.outputs.release_created == 'true' || (github.event_name == 'workflow_dispatch' && inputs.publish == true) }}
100+
run: python scripts/bundle_schemas.py
101+
98102
- name: Build package
99103
if: ${{ steps.release.outputs.release_created == 'true' || (github.event_name == 'workflow_dispatch' && inputs.publish == true) }}
100104
run: python -m build

src/adcp/validation/schema_loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ def _ensure_state(version: str | None = None) -> _LoaderState | None:
188188
return None
189189
root = _resolve_schema_root(bundle_key)
190190
if root is None:
191-
logger.debug(
191+
log_missing = logger.warning if version is None else logger.debug
192+
log_missing(
192193
"AdCP schemas not found for bundle_key=%s; validation will skip "
193194
"all tools for this version",
194195
bundle_key,

tests/test_schema_loader_per_version.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from __future__ import annotations
1212

1313
import json
14+
import logging
1415
import shutil
1516
from pathlib import Path
1617

@@ -190,6 +191,38 @@ def test_validate_request_unknown_version_skips_safely(
190191
assert outcome.issues == []
191192

192193

194+
def test_missing_sdk_pinned_bundle_warns(
195+
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
196+
) -> None:
197+
monkeypatch.setattr(_loader_mod, "_resolve_schema_root", lambda bundle_key=None: None)
198+
199+
_reset_for_tests()
200+
try:
201+
with caplog.at_level(logging.WARNING, logger="adcp.validation.schema_loader"):
202+
outcome = validate_request("synthetic_tool", {"x": 1})
203+
finally:
204+
_reset_for_tests()
205+
206+
assert outcome.valid
207+
assert any("AdCP schemas not found" in rec.message for rec in caplog.records)
208+
209+
210+
def test_missing_explicit_version_bundle_does_not_warn(
211+
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
212+
) -> None:
213+
monkeypatch.setattr(_loader_mod, "_resolve_schema_root", lambda bundle_key=None: None)
214+
215+
_reset_for_tests()
216+
try:
217+
with caplog.at_level(logging.WARNING, logger="adcp.validation.schema_loader"):
218+
outcome = validate_request("synthetic_tool", {"x": 1}, version="9.9.9")
219+
finally:
220+
_reset_for_tests()
221+
222+
assert outcome.valid
223+
assert not any("AdCP schemas not found" in rec.message for rec in caplog.records)
224+
225+
193226
def test_validate_response_threads_version_through(
194227
synthetic_legacy_bundle: tuple[str, Path],
195228
) -> None:

0 commit comments

Comments
 (0)