From 1d258626e07ca5f8cca568a8e36f379a542c2b29 Mon Sep 17 00:00:00 2001 From: tegwick Date: Fri, 21 Aug 2026 18:11:21 +0200 Subject: [PATCH] fix: fence deferred compatibility writes --- hub_core/runtime/compat.py | 8 +++++++- tests/test_compatibility.py | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hub_core/runtime/compat.py b/hub_core/runtime/compat.py index c535934..9fc8b7d 100644 --- a/hub_core/runtime/compat.py +++ b/hub_core/runtime/compat.py @@ -453,6 +453,12 @@ def create_compatibility_router() -> APIRouter: await _protected(request, "deferred", authorization) return {"data": []} + async def accept_deferred( + request: Request, authorization: AuthorizationHeader = None + ) -> dict: + await _protected(request, "deferred", authorization, write=True) + return {"data": []} + stem = path.replace("-", "_") router.add_api_route( f"/api/v2/{path}", @@ -462,7 +468,7 @@ def create_compatibility_router() -> APIRouter: ) router.add_api_route( f"/api/v2/{path}", - empty_collection, + accept_deferred, methods=["POST"], status_code=201, operation_id=f"compat_create_{stem}_{index}", diff --git a/tests/test_compatibility.py b/tests/test_compatibility.py index 8a3d5ed..470e92a 100644 --- a/tests/test_compatibility.py +++ b/tests/test_compatibility.py @@ -127,4 +127,7 @@ def test_read_only_group_rejects_write(tmp_path) -> None: assert response.status_code == 503 assert response.json()["detail"] == "compatibility group is read-only" + deferred = client.post("/annotations", headers=HEADERS) + assert deferred.status_code == 503 + assert deferred.json()["detail"] == "compatibility group is read-only" asyncio.run(store.aclose())