Skip to content

Commit 5942bac

Browse files
Conformance blocker: cover full skew refusal matrix beyond smoke (#188)
1 parent 6ab9baa commit 5942bac

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/durable_workflow/client.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import annotations
2020

2121
import asyncio
22+
import os
2223
import time
2324
import uuid
2425
import warnings
@@ -59,6 +60,14 @@ def _default_sdk_version() -> str:
5960
DEFAULT_SDK_VERSION = _default_sdk_version()
6061

6162

63+
def _protocol_version_from_env(name: str, default: str) -> str:
64+
value = os.environ.get(name)
65+
if value is None or value.strip() == "":
66+
return default
67+
68+
return value.strip()
69+
70+
6271
def _route_for_metrics(path: str) -> str:
6372
clean_path = path.split("?", 1)[0]
6473
parts = [part for part in clean_path.strip("/").split("/") if part]
@@ -1262,9 +1271,15 @@ def _headers(self, *, worker: bool = False) -> dict[str, str]:
12621271
h["Authorization"] = f"Bearer {token}"
12631272
h["X-Namespace"] = self.namespace
12641273
if worker:
1265-
h["X-Durable-Workflow-Protocol-Version"] = PROTOCOL_VERSION
1274+
h["X-Durable-Workflow-Protocol-Version"] = _protocol_version_from_env(
1275+
"DURABLE_WORKFLOW_WORKER_PROTOCOL_VERSION",
1276+
PROTOCOL_VERSION,
1277+
)
12661278
else:
1267-
h["X-Durable-Workflow-Control-Plane-Version"] = CONTROL_PLANE_VERSION
1279+
h["X-Durable-Workflow-Control-Plane-Version"] = _protocol_version_from_env(
1280+
"DURABLE_WORKFLOW_CONTROL_PLANE_VERSION",
1281+
CONTROL_PLANE_VERSION,
1282+
)
12681283
return h
12691284

12701285
def _auth_token(self, *, worker: bool = False) -> str | None:

tests/test_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ def test_worker_headers(self, client: Client) -> None:
5858
assert h["X-Durable-Workflow-Protocol-Version"] == PROTOCOL_VERSION
5959
assert "X-Durable-Workflow-Control-Plane-Version" not in h
6060

61+
def test_conformance_protocol_header_overrides(self, client: Client, monkeypatch: pytest.MonkeyPatch) -> None:
62+
monkeypatch.setenv("DURABLE_WORKFLOW_CONTROL_PLANE_VERSION", "3")
63+
monkeypatch.setenv("DURABLE_WORKFLOW_WORKER_PROTOCOL_VERSION", "2.0")
64+
65+
h = client._headers(worker=False)
66+
assert h["X-Durable-Workflow-Control-Plane-Version"] == "3"
67+
68+
worker_headers = client._headers(worker=True)
69+
assert worker_headers["X-Durable-Workflow-Protocol-Version"] == "2.0"
70+
6171
def test_no_token(self) -> None:
6272
c = Client("http://localhost:8080")
6373
h = c._headers()

0 commit comments

Comments
 (0)