From 0c24bb6a5e735a121fb61e535bbd1dcc3127d4be Mon Sep 17 00:00:00 2001 From: Jeff Dupont Date: Mon, 28 Sep 2026 11:56:59 -0700 Subject: [PATCH 1/2] [AIC-3484] fix(evaluations): send LD-API-Version on management API requests Pins 20240415 so evaluations calls made with a customer's token are not rejected when that token defaults below API v4. Co-authored-by: Cursor --- packages/client/src/launchdarkly_ai_server/evaluations/api.py | 2 ++ packages/client/tests/test_evaluations.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/client/src/launchdarkly_ai_server/evaluations/api.py b/packages/client/src/launchdarkly_ai_server/evaluations/api.py index 0a6aeb43..bd0b8dc4 100644 --- a/packages/client/src/launchdarkly_ai_server/evaluations/api.py +++ b/packages/client/src/launchdarkly_ai_server/evaluations/api.py @@ -13,6 +13,7 @@ from typing import Any, Protocol DEFAULT_BASE_URI = "https://app.launchdarkly.com" +_LD_API_VERSION = "20240415" # Only these methods are replayed after a 5xx or a transport failure: a POST that # timed out may still have created a record server-side. @@ -137,6 +138,7 @@ def request( headers = { "Authorization": self.api_token, "Accept": "application/json", + "LD-API-Version": _LD_API_VERSION, "User-Agent": "launchdarkly-ai-evaluations-python", } payload: bytes | None = None diff --git a/packages/client/tests/test_evaluations.py b/packages/client/tests/test_evaluations.py index 0a4ce0e3..e4c27226 100644 --- a/packages/client/tests/test_evaluations.py +++ b/packages/client/tests/test_evaluations.py @@ -203,6 +203,7 @@ def test_requests_carry_token_auth_and_json_body() -> None: assert request["method"] == "POST" assert request["url"] == f"{DEFAULT_BASE_URI}/api/v2/projects/proj/evaluations" assert request["headers"]["Authorization"] == "api-token" + assert request["headers"]["LD-API-Version"] == "20240415" assert request["headers"]["Content-Type"] == "application/json" assert request["body"] == {"key": "support-qa"} @@ -220,6 +221,7 @@ def test_get_encodes_query_params_and_omits_none() -> None: request["url"] == "https://ld.example.com/api/v2/projects/proj/datasets/golden?limit=50" ) + assert request["headers"]["LD-API-Version"] == "20240415" assert "Content-Type" not in request["headers"] From 02ee1971813e2a68c491de05b2ffa823536f2dc3 Mon Sep 17 00:00:00 2001 From: Jeff Dupont Date: Mon, 28 Sep 2026 13:55:12 -0700 Subject: [PATCH 2/2] [AIC-3484] refactor(evaluations): inline LD-API-Version value Matches the optimizer client in python-server-sdk-ai#216 and addresses review feedback: the value is used once, so keep it next to the header. Co-Authored-By: Claude Opus 5.5 --- packages/client/src/launchdarkly_ai_server/evaluations/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/client/src/launchdarkly_ai_server/evaluations/api.py b/packages/client/src/launchdarkly_ai_server/evaluations/api.py index bd0b8dc4..3a46d23d 100644 --- a/packages/client/src/launchdarkly_ai_server/evaluations/api.py +++ b/packages/client/src/launchdarkly_ai_server/evaluations/api.py @@ -13,7 +13,6 @@ from typing import Any, Protocol DEFAULT_BASE_URI = "https://app.launchdarkly.com" -_LD_API_VERSION = "20240415" # Only these methods are replayed after a 5xx or a transport failure: a POST that # timed out may still have created a record server-side. @@ -138,7 +137,7 @@ def request( headers = { "Authorization": self.api_token, "Accept": "application/json", - "LD-API-Version": _LD_API_VERSION, + "LD-API-Version": "20240415", "User-Agent": "launchdarkly-ai-evaluations-python", } payload: bytes | None = None