From 73faf9f1cac37e6d838661eb9a6b1c974f2b5292 Mon Sep 17 00:00:00 2001 From: codex-maintenance <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 30 Sep 2026 17:30:58 +0800 Subject: [PATCH] fix(reporting): identify account facts HTTP client Co-Authored-By: Codex --- scripts/publish_account_facts_from_report.py | 3 +++ tests/test_publish_ibkr_account_facts.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/scripts/publish_account_facts_from_report.py b/scripts/publish_account_facts_from_report.py index a1fb509..0ed3107 100644 --- a/scripts/publish_account_facts_from_report.py +++ b/scripts/publish_account_facts_from_report.py @@ -27,6 +27,7 @@ SOURCE_BINDING_KIND = "deployment_runtime_account" IBKR_ACCOUNT_FACTS_SYNC_TOKEN_ENV = "IBKR_ACCOUNT_FACTS_SYNC_TOKEN" IBKR_ACCOUNT_FACTS_SYNC_URL = "https://qsl-strategy-switch-console.pigbibi.workers.dev/api/account-facts/sync" +IBKR_ACCOUNT_FACTS_USER_AGENT = "QSL-IBKR-AccountFacts/1.0" IBKR_ACCOUNT_FACTS_INGRESS_DIAGNOSTIC_TARGET = "ingress-diagnostic" _INGRESS_DIAGNOSTIC_BODY = b"{}" _INGRESS_DIAGNOSTIC_ERROR = "invalid_account_facts_history" @@ -287,6 +288,7 @@ def publish_ibkr_account_facts_history( headers={ "Authorization": f"Bearer {_text(sync_token)}", "Content-Type": "application/json", + "User-Agent": IBKR_ACCOUNT_FACTS_USER_AGENT, }, method="POST", ) @@ -400,6 +402,7 @@ def diagnose_account_facts_ingress(*, sync_token: str) -> dict[str, Any]: headers={ "Authorization": f"Bearer {_text(sync_token)}", "Content-Type": "application/json", + "User-Agent": IBKR_ACCOUNT_FACTS_USER_AGENT, }, method="POST", ) diff --git a/tests/test_publish_ibkr_account_facts.py b/tests/test_publish_ibkr_account_facts.py index ad04706..d2c3e7b 100644 --- a/tests/test_publish_ibkr_account_facts.py +++ b/tests/test_publish_ibkr_account_facts.py @@ -226,6 +226,7 @@ def open(self, request, *, timeout): request = observed["request"] assert request.get_method() == "POST" assert request.get_header("Authorization") == "Bearer dedicated-test-token" + assert request.get_header("User-agent") == publisher.IBKR_ACCOUNT_FACTS_USER_AGENT assert json.loads(request.data)["account_ids"] == ["U16608560"] assert observed["timeout"] == 15 @@ -499,6 +500,7 @@ def open(self, request, *, timeout): assert request.data == b"{}" assert request.get_method() == "POST" assert request.get_header("Authorization") == "Bearer TOKEN_SENTINEL" + assert request.get_header("User-agent") == publisher.IBKR_ACCOUNT_FACTS_USER_AGENT assert request.get_header("Content-type") == "application/json" assert observed["calls"] == 1 assert observed["timeout"] == 15